using Publicuse.Appication;
using Publicuse.Autofac;
using Publicuse.Entity;
using Publicuse.Interface;
using Publicuse.Entity.AttributeUtil;
using Microsoft.AspNetCore.Http;
using Org.BouncyCastle.Bcpg.OpenPgp;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Publicuse.Util;
using Publicuse.Interface;
using Publicuse.Entity;

namespace Publicuse.Application
{
    /// <summary>
    /// 代码生成器模块应用
    /// </summary>
    public class GeneratorApplication
    {
        private static BaesApplication baseApplication;
        private static GeneratorApplication userApplication;

        public static GeneratorApplication GetApplication(ServiceContainer container)
        {
            baseApplication = new BaesApplication(container);
            return userApplication;
        }

        static GeneratorApplication()
        {
            userApplication = new GeneratorApplication();
        }

        /// <summary>
        /// 根据页面模板设置生成具体代码
        /// </summary>
        /// <param name="generators"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        public async Task<CommonResult> Restart(string path)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                if (path.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                }
                var paths = path.Split("\\");
                var index = 0;
                var pathstr = string.Empty;
                foreach (var item in paths)
                {
                    if (index <= paths.Length - 2)
                    {
                        pathstr += item + "\\";
                    }
                    index++;
                }
                var pathnew = pathstr + "start.bat";
                if (!FileUtil.Exists(pathnew))
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                }
                result.data = pathnew;
                //Process p = new Process();
                //p.StartInfo.FileName = "cmd.exe";
                //p.StartInfo.WorkingDirectory = pathstr;
                //p.StartInfo.UseShellExecute = false;
                //p.StartInfo.RedirectStandardInput = true;
                //p.StartInfo.RedirectStandardOutput = true;
                //p.StartInfo.RedirectStandardError = true;
                //p.StartInfo.CreateNoWindow = false;
                //p.Start();
                //p.StandardInput.WriteLine(pathnew);
                //Process[] processes = System.Diagnostics.Process.GetProcesses();
                //var curAppProecess = processes.Where(o => o.ProcessName == "Publicuse");
                //if (curAppProecess.Count()>=1)
                //{
                //    curAppProecess.FirstOrDefault().Kill();
                //}
                return result;
            });
        }

        /// <summary>
        /// 根据页面模板设置生成具体代码
        /// </summary>
        /// <param name="generators"></param>
        /// <param name="template"></param>
        /// <param name="type">1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> Generatordetailed(List<Generator> generators, GeneratorTemplate template,int type=1)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                if (generators.Count == 0)
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                var editindexs = generators.Where(o => o.isedit == true).Count();
                var queryindexs = generators.Where(o => o.isquery == true).Count();
                var titleindexs = generators.Where(o => o.istitle == true).Count();
                if (titleindexs == 0 || editindexs == 0 || queryindexs == 0)
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                var sameedit = generators.Where(o => o.isedit == true).DistinctBy(o => o.editindex).Count();
                var samequery = generators.Where(o => o.isquery == true).DistinctBy(o => o.queryindex).Count();
                var sametitle = generators.Where(o => o.istitle == true).DistinctBy(o => o.titleindex).Count();
                var dscl = generators.Where(o => o.iseditdsc == true).Count();
                if (editindexs != sameedit || queryindexs != samequery || titleindexs != sametitle || dscl == 0)
                {
                    result.msg = ImplementResult.ParameterException.GetRemark() + "：编辑，显示，查询不能有重复的索引";
                    return result;
                }
                var havedtsql = string.Empty;
                var havedt = false;
                var tableName = string.Empty;
                var tableRemark = string.Empty;
                var directoryname = string.Empty;
                string fileex = string.Empty;
                foreach (var query in generators)
                {
                    if (query.isadditional)
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(query.tableName))
                    {
                        tableName = query.tableName;
                        tableRemark = query.tableRemark;
                        directoryname = query.module.Split('-')[0];
                    }
                    if (query.querytype == 2 || query.querytype == 4 || query.querytype == 6)
                    {
                        havedt = true;
                        if (!string.IsNullOrEmpty(query.querystra))
                        {
                            var ql = query.querystra.Split('|');
                            if (ql.Length == 2)
                            {
                                if (ql[1].Split(',').Length == 2)
                                {
                                    havedtsql = query.querystra;
                                }
                                else
                                {
                                    fileex = query.name;
                                    break;
                                }
                            }
                            else
                            {
                                fileex = query.name;
                                break;
                            }
                        }
                        if (!string.IsNullOrEmpty(query.querystrc))
                        {
                            var ql = query.querystrc.Split('|');
                            if (ql.Length == 2)
                            {
                                if (ql[1].Split(',').Length == 2)
                                {
                                    havedtsql = query.querystrc;
                                }
                                else
                                {
                                    fileex = query.name;
                                    break;
                                }
                            }
                            else
                            {
                                fileex = query.name;
                                break;
                            }
                        }
                        if (query.querytype == 6 && string.IsNullOrEmpty(query.querystrc))
                        {
                            fileex = query.name;
                            break;
                        }
                        if (query.querytype != 6 && string.IsNullOrEmpty(query.querystra))
                        {

                            fileex = query.name;
                            break;
                        }
                    }
                    if (query.querytype == 1 || query.querytype == 3 || query.querytype == 5 || query.querytype == 12)
                    {
                        havedt = true;
                        if (!string.IsNullOrEmpty(query.querystrb))
                        {
                            try
                            {
                                var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(query.querystrb);
                                var ispass = true;
                                foreach (var item in pdata)
                                {
                                    if (item == null)
                                    {
                                        fileex = query.name;
                                        ispass = false;
                                        break;
                                    }
                                }
                                if (ispass)
                                {
                                    havedtsql = query.querystrb;
                                }
                                else
                                {
                                    fileex = query.name;
                                    break;
                                }
                            }
                            catch (Exception exa)
                            {
                                fileex = query.name;
                                havedt = true;
                                havedtsql = string.Empty;
                                break;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(query.checkdata))
                    {
                        try
                        {
                            var notequal = query.checkdata.Split(',')[1];
                        }
                        catch (Exception)
                        {
                            fileex = query.name;
                            havedt = true;
                            havedtsql = string.Empty;
                            break;
                        }
                    }
                }
                if (havedt && string.IsNullOrEmpty(havedtsql))
                {
                    result.msg = "字段：【" + fileex + "】" + ImplementResult.ParameterException.GetRemark() + "，请检查！";
                    return result;
                }

                Tbcodegeneration tbcodegeneration = new Tbcodegeneration()
                {
                    name = generators.Where(o => o.isadditional == false).FirstOrDefault()?.tableRemark,
                    code = generators.Where(o => o.isadditional == false).FirstOrDefault()?.tableName,
                    Remark = generators.Where(o => o.isadditional == false).FirstOrDefault()?.tableRemark,
                    content = JsonUtil.ListToJSON(generators),
                    status = 1
                };
                var tablname = TableAtributeUtil.GetTable<Tbcodegeneration>();
                var sql = $"select * from {tablname} where name ='{tbcodegeneration.name}';";
                var info = baseApplication.mySqlSugar.QueryBySql<Tbcodegeneration>(sql, out var msgb);
                var savetmp = new CommonResult();
                if (string.IsNullOrEmpty(msgb))
                {
                    if (info.Count > 0)
                    {
                        info.FirstOrDefault().name = tbcodegeneration.name;
                        info.FirstOrDefault().code = tbcodegeneration.code;
                        info.FirstOrDefault().Remark = tbcodegeneration.Remark;
                        info.FirstOrDefault().content = tbcodegeneration.content;
                        savetmp = baseApplication.AddOrUpdate<Tbcodegeneration>(info.FirstOrDefault(), BusinessType.tbcodegeneration, BusinessLogType.writeLogToDataBase).GetAwaiter().GetResult();
                    }
                    else
                    {
                        savetmp = baseApplication.AddOrUpdate<Tbcodegeneration>(tbcodegeneration, BusinessType.tbcodegeneration, BusinessLogType.writeLogToDataBase).GetAwaiter().GetResult();
                    }
                }
                //if (1 == 2)
                if (savetmp.success)
                {
                    #region 生成后台代码
                    if (!tableRemark.Contains("管理"))
                    {
                        tableRemark = tableRemark + "管理";
                    }
                    result = this.ExecuteBackstage(template.fileNameEntity, template.fileNameExport, template.fileNameApplication,
                        template.fileNameController, template.exportPath, tableName, tableRemark, baseApplication.mySqlSugar, generators).GetAwaiter().GetResult();
                    #endregion

                    if (!result.success)
                    {
                        #region 生成前端代码
                        result = this.ExecuteFrontend(template.fileNameModel, template.fileNameIndex, template.fileNameScss,
                            template.fileNameHtml, template.exportPath, tableName, tableRemark, directoryname, template.fileNameModule, template.fileNameRoute, true,
                            template.fileNameIndexAdd, template.fileNameHtmlAdd, template.fileNameShareModule,
                            baseApplication.mySqlSugar, generators,type).GetAwaiter().GetResult();
                        #endregion

                        if (result.success)
                        {
                            Task.Factory.StartNew(() =>
                            {
                                Menu infob = new Menu()
                                {
                                    aName = generators[0].rname,
                                    aCode = tbcodegeneration.code.Split('-')[1].TrimEnd('`'),
                                    ahtmlIcon = generators[0].ahtmlIcon,
                                    aisCURD = generators[0].checkOptionsOne,
                                    amoduleIndex = generators[0].rindex,
                                    aParentId = generators[0].aParentId,
                                    aType = 2,
                                    isedit = -1,
                                    ahtmlUrl = directoryname + "/" + tbcodegeneration.code.Split('-')[1].TrimEnd('`'),
                                    status = 1,
                                    Remark = generators[0].rname
                                };
                                if (!infob.aName.Contains("管理"))
                                {
                                    infob.aName = infob.aName + "管理";
                                }
                                tableName = TableAtributeUtil.GetTable<Menu>();
                                sql = $"select Id from {tableName} where aName='{infob.aName}' and status<>-9;";
                                var dte = baseApplication.mySqlSugar.GetDataTable(sql, out var msgd,null);
                                if (string.IsNullOrEmpty(msgd))
                                {
                                    if (dte.Rows.Count == 0)
                                    {
                                        var parentId = baseApplication.mySqlSugar.InserBackId(infob, out var msgc);
                                        if (string.IsNullOrEmpty(msgc))
                                        {
                                            List<Menu> list = new List<Menu>();
                                            AddResourceToChildren(list, infob, parentId, baseApplication.mySqlSugar);
                                        }
                                    }
                                }
                            });
                        }
                    }
                }
                return result;
            });
        }


        /// <summary>
        /// 绑定权限操作按钮资源
        /// </summary>
        /// <param name="list"></param>
        /// <param name="info"></param>
        /// <param name="parentId"></param>
        /// <param name="baseService"></param>
        private static void AddResourceToChildren(List<Menu> list, Menu info, long parentId, IMySqlSugarService baseService)
        {
            var msgb = string.Empty;
            List<Menu> listadd = new List<Menu>();
            var res = info.aisCURD.Split(',');
            if (res.Any(b => b == "1"))
            {
                Menu add = new Menu();
                add.aapiUrl = "api/" + info.aCode + "/" + "CheckAdd";
                add.status = 1;
                add.aName = info.aName.Replace("管理", "") + "新增";
                add.aParentId = parentId;
                add.ahtmlIcon = string.Empty;
                add.ahtmlUrl = string.Empty;
                add.aCode = info.aCode + "Add";
                add.aType = 3;
                add.abIndex = 1;
                var havedata = list.Where(o => o.aapiUrl == add.aapiUrl);
                if (havedata.Count() > 0)
                {
                    add.uTime = DateTime.Now;
                    add.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(add);
            }
            if (res.Any(b => b == "2"))
            {
                Menu delete = new Menu();
                delete.aapiUrl = "api/" + info.aCode + "/" + "CheckDelete";
                delete.status = 1;
                delete.aName = info.aName.Replace("管理", "") + "删除";
                delete.ahtmlIcon = string.Empty;
                delete.ahtmlUrl = string.Empty;
                delete.aParentId = parentId;
                delete.aCode = info.aCode + "Delete";
                delete.aType = 3;
                delete.abIndex = 2;
                var havedata = list.Where(o => o.aapiUrl == delete.aapiUrl);
                if (havedata.Count() > 0)
                {
                    delete.uTime = DateTime.Now;
                    delete.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(delete);
            }
            if (res.Any(b => b == "3"))
            {
                Menu update = new Menu();
                update.aapiUrl = "api/" + info.aCode + "/" + "CheckUpdate";
                update.status = 1;
                update.aName = info.aName.Replace("管理", "") + "修改";
                update.aParentId = parentId;
                update.ahtmlIcon = string.Empty;
                update.ahtmlUrl = string.Empty;
                update.aCode = info.aCode + "Update";
                update.aType = 3;
                update.abIndex = 3;
                var havedata = list.Where(o => o.aapiUrl == update.aapiUrl);
                if (havedata.Count() > 0)
                {
                    update.uTime = DateTime.Now;
                    update.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(update);
            }
            if (res.Any(b => b == "4"))
            {
                Menu query = new Menu();
                query.aapiUrl = "api/" + info.aCode + "/" + "CheckGetList";
                query.status = 1;
                query.aName = info.aName.Replace("管理", "") + "查询";
                query.ahtmlIcon = string.Empty;
                query.ahtmlUrl = string.Empty;
                query.aParentId = parentId;
                query.aCode = info.aCode + "GetData";
                query.aType = 3;
                query.abIndex = 4;
                var havedata = list.Where(o => o.aapiUrl == query.aapiUrl);
                if (havedata.Count() > 0)
                {
                    query.uTime = DateTime.Now;
                    query.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(query);
            }
            if (res.Any(b => b == "5"))
            {
                Menu import = new Menu();
                import.aapiUrl = "api/" + info.aCode + "/" + "CheckImport";
                import.status = 1;
                import.aName = info.aName.Replace("管理", "") + "导入";
                import.ahtmlIcon = string.Empty;
                import.ahtmlUrl = string.Empty;
                import.aParentId = parentId;
                import.aCode = info.aCode + "Import";
                import.aType = 3;
                import.abIndex = 5;
                var havedata = list.Where(o => o.aapiUrl == import.aapiUrl);
                if (havedata.Count() > 0)
                {
                    import.uTime = DateTime.Now;
                    import.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(import);
            }
            if (res.Any(b => b == "6"))
            {
                Menu export = new Menu();
                export.aapiUrl = "api/" + info.aCode + "/" + "CheckExport";
                export.status = 1;
                export.aName = info.aName.Replace("管理", "") + "导出";
                export.ahtmlIcon = string.Empty;
                export.ahtmlUrl = string.Empty;
                export.aParentId = parentId;
                export.aCode = info.aCode + "Export";
                export.aType = 3;
                export.abIndex = 6;
                var havedata = list.Where(o => o.aapiUrl == export.aapiUrl);
                if (havedata.Count() > 0)
                {
                    export.uTime = DateTime.Now;
                    export.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(export);
            }
            if (res.Any(b => b == "7"))
            {
                Menu down = new Menu();
                down.aapiUrl = "api/" + info.aCode + "/" + "CheckDown";
                down.status = 1;
                down.aName = info.aName.Replace("管理", "") + "下载导入模板";
                down.ahtmlIcon = string.Empty;
                down.ahtmlUrl = string.Empty;
                down.aParentId = parentId;
                down.aCode = info.aCode + "Down";
                down.aType = 3;
                down.abIndex = 7;
                var havedata = list.Where(o => o.aapiUrl == down.aapiUrl);
                if (havedata.Count() > 0)
                {
                    down.uTime = DateTime.Now;
                    down.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(down);
            }
            if (res.Any(b => b == "8"))
            {
                Menu upload = new Menu();
                upload.aapiUrl = "api/" + info.aCode + "/" + "CheckUpload";
                upload.status = 1;
                upload.aName = info.aName.Replace("管理", "") + "上传文件";
                upload.aParentId = parentId;
                upload.ahtmlIcon = string.Empty;
                upload.ahtmlUrl = string.Empty;
                upload.aCode = info.aCode + "Upload";
                upload.aType = 3;
                upload.abIndex = 8;
                var havedata = list.Where(o => o.aapiUrl == upload.aapiUrl);
                if (havedata.Count() > 0)
                {
                    upload.uTime = DateTime.Now;
                    upload.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(upload);
            }
            if (res.Any(b => b == "9"))
            {
                Menu audit = new Menu();
                audit.aapiUrl = "api/" + info.aCode + "/" + "CheckAudit";
                audit.status = 1;
                audit.aName = info.aName.Replace("管理", "") + "审核";
                audit.aParentId = parentId;
                audit.ahtmlIcon = string.Empty;
                audit.ahtmlUrl = string.Empty;
                audit.aCode = info.aCode + "Audit";
                audit.aType = 3;
                audit.abIndex = 9;
                var havedata = list.Where(o => o.aapiUrl == audit.aapiUrl);
                if (havedata.Count() > 0)
                {
                    audit.uTime = DateTime.Now;
                    audit.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(audit);
            }
            if (res.Any(b => b == "10"))
            {
                Menu roleresource = new Menu();
                roleresource.aapiUrl = "api/" + info.aCode + "/" + "CheckRoleResource";
                roleresource.status = 1;
                roleresource.aName = info.aName.Replace("管理", "") + "角色资源";
                roleresource.aParentId = parentId;
                roleresource.ahtmlIcon = string.Empty;
                roleresource.ahtmlUrl = string.Empty;
                roleresource.aCode = info.aCode + "RoleResource";
                roleresource.aType = 3;
                roleresource.abIndex = 10;
                var havedata = list.Where(o => o.aapiUrl == roleresource.aapiUrl);
                if (havedata.Count() > 0)
                {
                    roleresource.uTime = DateTime.Now;
                    roleresource.Id = havedata.FirstOrDefault().Id;
                }
                listadd.Add(roleresource);
            }
            foreach (var item in listadd)
            {
                if (item.Id > 0)
                    baseService.Update(item, out msgb);
                else
                    baseService.Insert(item, out msgb);
            }
        }

        /// <summary>
        /// 生成后台模块代码
        /// </summary>
        /// <param name="fileNameEntity">实体模板路径</param>
        /// <param name="fileNameExport">导出模板路径</param>
        /// <param name="fileNameApplication">应用模板路径</param>
        /// <param name="fileNameController">控制器模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteBackstage(string fileNameEntity, string fileNameExport, string fileNameApplication,
            string fileNameController, string exportPath, string model, string module, IMySqlSugarService service, List<Generator> generators)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                if (fileNameEntity.IsNull() || fileNameExport.IsNull() || fileNameApplication.IsNull() || fileNameController.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(fileNameEntity) || !FileUtil.Exists(fileNameExport) || !FileUtil.Exists(fileNameApplication) || !FileUtil.Exists(fileNameController))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                result = Task.Factory.StartNew<CommonResult>(() =>
                 {
                     return ExecuteEntity(fileNameEntity, exportPath, model, module, generators).GetAwaiter().GetResult(); //生成实体模块信息
                 }).ContinueWith(r =>
                 {
                     result = r.GetAwaiter().GetResult();
                     if (result.success)
                     {
                         return ExecuteExport(fileNameExport, exportPath, model, module, generators).GetAwaiter().GetResult(); //生成导出模块信息
                     }
                     return result;
                 }).ContinueWith(r =>
                 {
                     result = r.GetAwaiter().GetResult();
                     if (result.success)
                     {
                         return ExecuteApplication(fileNameApplication, exportPath, model, module, service, generators).GetAwaiter().GetResult(); //生成应用模块信息
                     }
                     return result;
                 }).ContinueWith(r =>
                 {
                     result = r.GetAwaiter().GetResult();
                     if (result.success)
                     {
                         return ExecuteController(fileNameController, exportPath, model, module, service, generators).GetAwaiter().GetResult(); //生成控制器模块信息
                     }
                     return result;
                 }).GetAwaiter().GetResult();
                return result;
            });
        }

        /// <summary>
        /// 生成前端模块代码
        /// </summary>
        /// <param name="fileNameModel">Model模板路径</param>
        /// <param name="fileNameIndex">Index模板路径</param>
        /// <param name="fileNameScss">Scss模板路径</param>
        /// <param name="fileNameHtml">Html模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="directoryname">所属模块目录名称</param>
        /// <param name="fileNameModule">Module模板路径</param>
        /// <param name="fileNameRoute">Route模板路径</param>
        /// <param name="isedit">是否生成编辑页面</param> 
        /// <param name="fileNameIndexAdd">IndexAdd模板路径</param>
        /// <param name="fileNameHtmlAdd">HtmlAdd模板路径</param>
        /// <param name="fileNameShareModule">SharModule模板路径</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <param name="type">类型 1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteFrontend(string fileNameModel, string fileNameIndex, string fileNameScss, string fileNameHtml,
            string exportPath, string model, string module, string directoryname, string fileNameModule,
            string fileNameRoute, bool isedit, string fileNameIndexAdd, string fileNameHtmlAdd, string fileNameShareModule,
            IMySqlSugarService service, List<Generator> generators, int type)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                if (fileNameModel.IsNull() || fileNameIndex.IsNull() || fileNameScss.IsNull() || fileNameHtml.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull() || directoryname.IsNull() || fileNameModule.IsNull() || fileNameRoute.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(fileNameModel) || !FileUtil.Exists(fileNameIndex) || !FileUtil.Exists(fileNameScss) || !FileUtil.Exists(fileNameHtml) || !FileUtil.Exists(fileNameModule) || !FileUtil.Exists(fileNameRoute))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                result = Task.Factory.StartNew<CommonResult>(() =>
                {
                    return ExecuteModel(fileNameModel, exportPath, model, module, directoryname, service, generators,type).GetAwaiter().GetResult(); //生成Model模块信息
                }).ContinueWith(r =>
                {
                    result = r.GetAwaiter().GetResult();
                    if (result.success)
                    {
                        return ExecuteScss(fileNameScss, exportPath, model, directoryname, isedit, service, type).GetAwaiter().GetResult(); //生成Scss模块信息
                    }
                    return result;
                }).ContinueWith(r =>
                {
                    result = r.GetAwaiter().GetResult();
                    if (result.success)
                    {
                        ExecuteIndex(fileNameIndex, exportPath, model, directoryname, isedit, fileNameIndexAdd, service, generators, type).GetAwaiter(); //生成Index模块信息
                    }
                    return result;
                }).ContinueWith(r =>
                {
                    result = r.GetAwaiter().GetResult();
                    if (result.success)
                    {
                        ExecuteHtml(fileNameHtml, exportPath, model, module, directoryname, fileNameModule, fileNameRoute, isedit, fileNameHtmlAdd, fileNameShareModule, service, generators, type).GetAwaiter(); //生成Html模块信息
                    }
                    return result;
                }).GetAwaiter().GetResult();
                return result;
            });
        }



        /// <summary>
        /// 获取数据库表信息
        /// </summary>
        /// <param name="service"></param>
        /// <param name="table"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List<Databasemanagement> GetTableInfo(IMySqlSugarService mySqlSugar, string table, out string msg)
        {
            msg = string.Empty;
            var sql = $"select a.COLUMN_NAME,a.TABLE_NAME,a.IS_NULLABLE,a.COLUMN_TYPE,a.COLUMN_KEY,a.COLUMN_DEFAULT,a.COLUMN_COMMENT,b.`AUTO_INCREMENT`,b.TABLE_COMMENT from INFORMATION_SCHEMA.columns a left join INFORMATION_SCHEMA.TABLES b on a.TABLE_NAME=b.TABLE_NAME where a.table_schema = 'tongji' and a.table_name='{table}'";
            List<Databasemanagement> tablelist = new List<Databasemanagement>();
            var dt = mySqlSugar.GetDataTable(sql, null, out msg);
            if (string.IsNullOrEmpty(msg))
            {
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        var TABLE_NAME = item["TABLE_NAME"].ToString();
                        var IS_NULLABLE = item["IS_NULLABLE"].ToString();
                        var COLUMN_NAME = item["COLUMN_NAME"].ToString();
                        var COLUMN_TYPE = item["COLUMN_TYPE"].ToString();
                        var COLUMN_KEY = item["COLUMN_KEY"].ToString();
                        var COLUMN_DEFAULT = item["COLUMN_DEFAULT"].ToString();
                        var COLUMN_COMMENT = item["COLUMN_COMMENT"].ToString();
                        var AUTO_INCREMENT = item["AUTO_INCREMENT"].ToString();
                        var TABLE_COMMENT = item["TABLE_COMMENT"].ToString();
                        Databasemanagement info = new Databasemanagement()
                        {
                            tableName = TABLE_NAME,
                            tableRemark = TABLE_COMMENT,
                            isnull = IS_NULLABLE,
                            fileName = COLUMN_NAME,
                            fileType = COLUMN_TYPE,
                            fileRemark = COLUMN_COMMENT,
                            primaryKeyName = COLUMN_KEY,
                            defaultvalue = COLUMN_DEFAULT,
                            autoIndex = AUTO_INCREMENT.GetIntValue(),
                        };
                        tablelist.Add(info);
                    }
                }
            }
            return tablelist;
        }

        /// <summary>
        /// 导出Excel模板上传
        /// </summary>
        /// <param name="files"></param>
        /// <param name="path"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public async Task<CommonResult> UploadExportFile(IFormFileCollection files, string path, string module)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                path = path + "\\template\\report\\";
                if (!FileUtil.ExistsDir(path))
                    FileUtil.CreateDirectory(path);

                foreach (var formFile in files)
                {
                    if (formFile.Length > 0)
                    {
                        var filePath = path + module + "." + formFile.FileName.Split('.')[1];
                        using (var stream = new FileStream(filePath, FileMode.Create))
                        {
                            formFile.CopyTo(stream);
                        }
                        result.data = "//template//report//" + module;
                    }
                }
                return result;
            });
        }

        /// <summary>
        /// 导入Excel模板上传
        /// </summary>
        /// <param name="files"></param>
        /// <param name="path"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public async Task<CommonResult> UploadImportFile(IFormFileCollection files, string path, string module)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                path = path + "\\down\\";
                if (!FileUtil.ExistsDir(path))
                    FileUtil.CreateDirectory(path);

                foreach (var formFile in files)
                {
                    if (formFile.Length > 0)
                    {
                        var filePath = path + module + "." + formFile.FileName.Split('.')[1];
                        using (var stream = new FileStream(filePath, FileMode.Create))
                        {
                            formFile.CopyTo(stream);
                        }
                        result.data = "//down//" + module;
                    }
                }
                return result;
            });
        }

        /// <summary>
        /// 生成后台Entity实体模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="generators">模板设置信息</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteEntity(string file, string exportPath, string model, string module, List<Generator> generators)
        {
            return await Task.Factory.StartNew(() =>
            {
                model = model.Replace("`", "").Split('-')[1].ToLower();
                CommonResult result = new CommonResult();
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                string generatorpath = newpath + path[path.Length - 1].Replace(path[path.Length - 1], path[path.Length - 1] + ".Entity");
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                    return result;
                }

                //没有使用导出Excel模板时 根据查询显示字段顺序对应导出数据
                if (generators.Any(o => o.exporttemplate == "") == true)
                {
                    Task.Factory.StartNew(() =>
                    {
                        string filepath = exportPath + "\\wwwroot\\template\\report\\" + model.ToLower() + ".xls";
                        ExcelUtil.GetExcelUtil.InitExcel(module + "统计信息", generators, filepath, out var msgb);
                    });
                }
                var entityname = model.FirstCharToUpper();
                var routemodule = generators.FirstOrDefault().module.Split('-')[0];
                var filename = $"{entityname}.cs";
                if (!FileUtil.Exists(generatorpath + "\\"+routemodule +"\\"+ filename))
                {
                    StringBuilder entitymodel = new StringBuilder();
                    int index = 0;
                    foreach (var item in generators)
                    {
                        if (string.Compare(item.file.ToUpper(), "Remark".ToUpper(), true) != 0 && string.Compare(item.file.ToUpper(), "status".ToUpper(), true) != 0 &&
                        string.Compare(item.file.ToUpper(), "Id".ToUpper(), true) != 0 && string.Compare(item.file.ToUpper(), "ctime".ToUpper(), true) != 0 &&
                        string.Compare(item.file.ToUpper(), "utime".ToUpper(), true) != 0)
                        {
                            if (item.isadditional)
                            {
                                continue;
                            }
                            string fileremark = item.name;
                            if (fileremark.IsNull())
                            {
                                fileremark = item.file;
                            }
                            if (index == 0)
                            {
                                entitymodel.Append("\t[Remark(\"" + fileremark + "\")]\n");
                                if (item.isnullb)
                                {
                                    entitymodel.Append("\t\t[Required]\n");
                                }
                                if (!string.IsNullOrEmpty(item.fileformat))
                                {
                                    entitymodel.Append("\t\t" + item.fileformat.Replace("%", @"\") + "\n");
                                }
                            }
                            else
                            {
                                entitymodel.Append("\t\t[Remark(\"" + fileremark + "\")]\n");
                                if (item.isnullb)
                                {
                                    entitymodel.Append("\t\t[Required]\n");
                                }
                                if (!string.IsNullOrEmpty(item.fileformat))
                                {
                                    entitymodel.Append("\t\t" + item.fileformat.Replace("%", @"\") + "\n");
                                }
                            }
                            index++;
                            if (item.fileType.Contains("int") || item.fileType.Contains("decimal") || item.fileType.Contains("smallint") || item.fileType.Contains("tinyint"))
                            {
                                entitymodel.Append("\t\t public int " + item.file + " { get; set; } = -1; \n\n");
                            }
                            if (item.fileType.Contains("varchar"))
                            {
                                entitymodel.Append("\t\t public string " + item.file + " { get; set; }\n\n");
                            }
                            if (item.fileType.Contains("datetime") || item.fileType.Contains("date"))
                            {
                                entitymodel.Append("\t\t public DateTime " + item.file + " { get; set; }\n\n");
                            }
                            if (item.fileType.Contains("double"))
                            {
                                entitymodel.Append("\t\t public double " + item.file + " { get; set; } = -1; \n\n");
                            }
                            if (item.fileType.Contains("text"))
                            {
                                entitymodel.Append("\t\t public string " + item.file + " { get; set; }\n\n");
                            }
                        }
                    }
                    if (module.IsNull())
                    {
                        module = generators[0]?.tableRemark;
                    }
                    entitymodel.Append("\t\t public " + model.FirstCharToUpper() + "() \n\t\t { \n\t\t\t this.Id=0; \n\t\t }");
                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }
                    var table = model;
                    string newjson = json.Replace("template", table).Replace("table", entityname).Replace("模板", module).Replace("epname", model.ToLower()).Replace("entitymodel", entitymodel.ToString());
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                        return result;
                    }
                    if (!FileUtil.Exists(generatorpath + "\\" + routemodule + "\\" +filename))
                    {
                        FileUtil.WriteFile(generatorpath + "\\" + routemodule, filename, newjson);
                        string newmodule = string.Empty;
                        if (module.Contains("管理"))
                        {
                            newmodule = module;
                        }
                        else
                        {
                            newmodule = module + "管理";
                        }
                        //添加日志模块标识
                        filename = "BusinessType.cs";
                        if (FileUtil.Exists(generatorpath + "\\other\\" + filename))
                        {
                            json = FileUtil.ReadFile(generatorpath + "\\other\\" + filename);
                            string[] datalen = json.Split(',');
                            int maxindex = datalen[datalen.Length - 2].Split('=')[1].GetIntValue() + 1;
                            string addtypedata = ",\n\n\t\t///\t<summary>\n\t\t///\t" + newmodule + "\n\t\t///\t</summary>\n\t\t[BusinessAttribute(\"" + newmodule + "\")]\n\t\t" + model + " = " + maxindex + "";
                            json = json.Insert(json.LastIndexOf(','), addtypedata);
                            FileUtil.WriteFile(generatorpath + "\\other", filename, json);
                        }
                    }
                }
                return result;
            });
        }

        /// <summary>
        /// 生成后台Controller控制器模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteController(string file, string exportPath, string model, string module, IMySqlSugarService service, List<Generator> generators)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                model = model.Replace("`", "").Split('-')[1];
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                string generatorpath = exportPath + "\\Controllers";
                var filename = $"{model.FirstCharToUpper()}Controller.cs";
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                    return result;
                }
                var routemodule = generators.FirstOrDefault().module.Split('-')[0];
                if (!FileUtil.Exists(generatorpath + "\\" + routemodule + "\\" +filename))
                {
                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }

                    #region 唯一字段校验设置
                    StringBuilder checkstr = new StringBuilder();
                    var checklist = generators.Where(o => o.isedit == true && o.isonly != "").OrderBy(o => o.editindex);
                    var cind = 0;
                    foreach (var item in checklist)
                    {
                        if (cind == 0)
                        {
                            checkstr.Append("/// <summary>\n\t\t/// 检查" + module + "模块" + item.name + "是否存在\n\t\t/// </summary>\n");
                        }
                        else
                        {
                            checkstr.Append("\t\t/// <summary>\n\t\t/// 检查" + module + "模块" + item.name + "是否存在\n\t\t/// </summary>\n");
                        }
                        var isonlys = item.isonly.Split(',');
                        if (isonlys.Length > 1)
                        {
                            foreach (var itemb in isonlys)
                            {
                                checkstr.Append("\t\t/// <param name=\"" + itemb + "\"></param>\n");
                            }
                        }
                        else
                        {
                            checkstr.Append("\t\t/// <param name=\"" + isonlys[0] + "\"></param>\n");
                        }
                        checkstr.Append("\t\t/// <param name=\"loginUserCode\"></param>\n\t\t/// <param name=\"Id\"></param>\n\t\t/// <returns></returns>\n\t\t[HttpGet(\"Check" + item.file.FirstCharToUpper() + "\"), AllowAnonymous]\n");
                        if (isonlys.Length > 1)
                        {
                            string ckfile = string.Empty;
                            string ckfileb = string.Empty;
                            string ckfilec = string.Empty;
                            string ckfiled = string.Empty;
                            var index = 0;
                            foreach (var itemc in isonlys)
                            {
                                if (index < isonlys.Length - 1)
                                {
                                    ckfileb += "" + itemc + "='{" + (index + 1) + "}' and ";
                                    ckfilec += "" + itemc + ",";
                                    ckfiled += "" + itemc + "+ \"|\" +";
                                }
                                else
                                {
                                    ckfileb += "" + itemc + "='{" + (index + 1) + "}'  ";
                                    ckfilec += "" + itemc + "";
                                    ckfiled += "" + itemc + "+ \"|\" ";
                                }
                                if (item.fileType.Contains("int"))
                                {
                                    ckfile += "int " + itemc + ",";
                                }
                                if (item.fileType.Contains("varchar"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                if (item.fileType.Contains("datetime"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                if (item.fileType.Contains("double"))
                                {
                                    ckfile += "int " + itemc + ",";
                                }
                                if (item.fileType.Contains("text"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                index++;
                            }
                            ckfile = ckfile.TrimEnd(',');
                            ckfilec = ckfilec.TrimEnd(',');
                            ckfiled = ckfiled.TrimEnd('+');
                            checkstr.Append("\t\tpublic async Task<JsonResult> Check" + item.file.FirstCharToUpper() + "(" + ckfile + ", string loginUserCode, string Id = \"\")\n\t\t{");
                            checkstr.Append("\n\t\t\tCommonResult result = await " + model.FirstCharToUpper() + "Application.GetApplication(this.container).Check" + item.file.FirstCharToUpper() + "(" + ckfilec + ", loginUserCode, Id);");
                            checkstr.Append("\n\t\t\treturn new JsonResult(result);\n\t\t}\n\n");
                        }
                        else
                        {
                            checkstr.Append("\t\tpublic async Task<JsonResult> Check" + item.file.FirstCharToUpper() + "(string " + isonlys[0] + ", string loginUserCode, string Id = \"\")\n\t\t{");
                            checkstr.Append("\n\t\t\tCommonResult result = await " + model.FirstCharToUpper() + "Application.GetApplication(this.container).Check" + item.file.FirstCharToUpper() + "(" + isonlys[0] + ", loginUserCode, Id);");
                            checkstr.Append("\n\t\t\treturn new JsonResult(result);\n\t\t}\n\n");
                        }
                        cind++;
                    }
                    #endregion

                    #region 字段下拉查询动态值设置
                    StringBuilder querystr = new StringBuilder();
                    var havedt = false;
                    var havedtsql = string.Empty;
                    foreach (var query in generators)
                    {
                        if (query.querytype == 2 || query.querytype == 4 || query.querytype == 6)
                        {
                            var autovalue = string.Empty;
                            var querycon = string.Empty;
                            if (query.querytype == 6 && !string.IsNullOrEmpty(query.autovalue))
                            {
                                autovalue = "\n\t\t\t/// <param name=\"" + query.autovalue + "\"></param>";
                                querycon = "string " + query.autovalue + "";
                            }
                            havedt = true;
                            querystr.Append("\n\t\t/// <summary>\n\t\t///获取" + query.name + "集合信息\n\t\t/// </summary>" + autovalue + "\n\t\t/// <returns></returns>\n");
                            querystr.Append("\t\t[HttpGet(\"Get" + query.file.FirstCharToUpper() + "List\"),AllowAnonymous]\n\t\tpublic async Task<JsonResult> Get" + query.file.FirstCharToUpper() + "List(" + querycon + ")\n\t\t{\n");
                            querystr.Append("\t\t\tCommonResult result = await " + model.FirstCharToUpper() + "Application.GetApplication(this.container).Get" + query.file.FirstCharToUpper() + "List(" + query.autovalue + ");\n");
                            querystr.Append("\t\t\treturn new JsonResult(result);\n\t\t}\n");
                            if (!string.IsNullOrEmpty(query.querystra))
                            {
                                havedtsql = query.querystra;
                            }
                            if (!string.IsNullOrEmpty(query.querystrc))
                            {
                                havedtsql = query.querystrc;
                            }
                        }
                    }
                    if (havedt && string.IsNullOrEmpty(havedtsql))
                    {
                        result.msg = ImplementResult.ParameterException.GetRemark();
                        return result;
                    }
                    #endregion

                    #region 设置头像上传信息
                    StringBuilder htrtmp = new StringBuilder();
                    var fulist = generators.Where(o => o.querytype == 10).OrderBy(o => o.editindex);
                    foreach (var item in fulist)
                    {
                        htrtmp.Append("/// <summary>\n\t\t\t/// 上传" + item.name + "头像\n\t\t\t/// </summary>\n\t\t\t/// <returns></returns>\n\t\t\t");
                        htrtmp.Append("[HttpPost(\"Upload" + item.file.FirstCharToUpper() + "Head\"), AllowAnonymous]\n\t\t\t");
                        htrtmp.Append("public async Task<JsonResult> Upload" + item.file.FirstCharToUpper() + "Head()\n\t\t\t{\n\t\t\t");
                        htrtmp.Append("string path = this._hostingEnvironment.WebRootPath;\n\t\t\t");
                        htrtmp.Append("var files = Request.Form.Files;\n\t\t\t");
                        htrtmp.Append("UploadYPhoto model = new UploadYPhoto()\n\t\t\t{\n\t\t\tuid = Request.Query.FirstOrDefault().Value.ToString(),\n\t\t\tlogincode = Request.Query.LastOrDefault().Value.ToString()\n\t\t\t};\n\t\t\t");
                        htrtmp.Append("var result= await this.UploadFile<" + model.FirstCharToUpper() + ">(files, model.logincode, \"上传" + item.tableName + "头像\", model, this._hostingEnvironment.WebRootPath, BusinessType." + model.FirstCharToLower() + ");\n\t\t\t");
                        htrtmp.Append("return new JsonResult(result);\n\t\t\t}\n\t\t\t");
                    }
                    #endregion

                    #region 设置文件上传信息
                    StringBuilder uftmp = new StringBuilder();
                    var fulistb = generators.Where(o => o.querytype == 11).OrderBy(o => o.editindex);
                    foreach (var item in fulistb)
                    {
                        uftmp.Append("/// <summary>\n\t\t\t/// " + item.name + "附件上传\n\t\t\t/// </summary>\n\t\t\t/// <returns></returns>\n\t\t\t");
                        uftmp.Append("[HttpPost(\"UploadFile" + item.file.FirstCharToUpper() + "\"), AllowAnonymous]\n\t\t\t");
                        uftmp.Append("public async Task<JsonResult> UploadFile" + item.file.FirstCharToUpper() + "()\n\t\t\t{\n\t\t\t");
                        uftmp.Append("string path = this._hostingEnvironment.WebRootPath;\n\t\t\t");
                        uftmp.Append("var files = Request.Form.Files;\n\t\t\t");
                        uftmp.Append("CommonResult result = await " + model.FirstCharToUpper() + "Application.GetApplication(this.container).UploadFile" + item.file.FirstCharToUpper() + "(files, path);\n\t\t\t");
                        uftmp.Append("return new JsonResult(result);\n\t\t\t}\n\t\t\t");
                    }
                    #endregion

                    string newjson = json.Replace("Template", model.FirstCharToUpper())
                    .Replace("模板", module)
                    .Replace("htrtmp", htrtmp.ToString())
                    .Replace("uftmp", uftmp.ToString())
                    .Replace("epname", model.ToLower())
                    .Replace("cktmp", checkstr.ToString())
                    .Replace("qstmp", querystr.ToString());
                    FileUtil.WriteFile(generatorpath + "\\" + routemodule, filename, newjson);
                }
                return result;
            });
        }

        /// <summary>
        /// 生成后台Application应用模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteApplication(string file, string exportPath, string model, string module, IMySqlSugarService service, List<Generator> generators)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                model = model.Replace("`", "").Split('-')[1];
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                string generatorpath = newpath + "\\" + path[path.Length - 1].Replace(path[path.Length - 1], path[path.Length - 1] + ".Application");
                var filename = $"{model.FirstCharToUpper()}Application.cs";
                var routemodule = generators.FirstOrDefault().module.Split('-')[0];
                if (!FileUtil.Exists(generatorpath + "\\" + routemodule + "\\" + filename))
                {
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                        return result;
                    }
                    #region 唯一字段校验设置
                    StringBuilder checkstr = new StringBuilder();
                    var checklist = generators.Where(o => o.isedit == true && o.isonly != "").OrderBy(o => o.editindex);
                    var cind = 0;
                    foreach (var item in checklist)
                    {
                        if (cind == 0)
                        {
                            checkstr.Append("/// <summary>\n\t\t/// 检查" + module + "模块" + item.name + "是否存在\n\t\t/// </summary>\n");
                        }
                        else
                        {
                            checkstr.Append("\t\t/// <summary>\n\t\t/// 检查" + module + "模块" + item.name + "是否存在\n\t\t/// </summary>\n");
                        }
                        var isonlys = item.isonly.Split(',');
                        if (isonlys.Length > 1)
                        {
                            foreach (var itemb in isonlys)
                            {
                                checkstr.Append("\t\t/// <param name=\"" + itemb + "\"></param>\n");
                            }
                        }
                        else
                        {
                            checkstr.Append("\t\t/// <param name=\"" + isonlys[0] + "\"></param>\n");
                        }
                        checkstr.Append("\t\t/// <param name=\"loginUserCode\"></param>\n\t\t/// <param name=\"Id\"></param>\n\t\t/// <returns></returns>\n");
                        if (isonlys.Length > 1)
                        {
                            string ckfile = string.Empty;
                            string ckfileb = string.Empty;
                            string ckfilec = string.Empty;
                            string ckfiled = string.Empty;
                            var index = 0;
                            foreach (var itemc in isonlys)
                            {
                                if (index < isonlys.Length - 1)
                                {
                                    ckfileb += "" + itemc + "='{" + (index + 1) + "}' and ";
                                    ckfilec += "" + itemc + ",";
                                    ckfiled += "" + itemc + "+ \"|\" +";
                                }
                                else
                                {
                                    ckfileb += "" + itemc + "='{" + (index + 1) + "}'  ";
                                    ckfilec += "" + itemc + "";
                                    ckfiled += "" + itemc + "+ \"|\" ";
                                }
                                if (item.fileType.Contains("int"))
                                {
                                    ckfile += "int " + itemc + ",";
                                }
                                if (item.fileType.Contains("varchar"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                if (item.fileType.Contains("datetime"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                if (item.fileType.Contains("double"))
                                {
                                    ckfile += "int " + itemc + ",";
                                }
                                if (item.fileType.Contains("text"))
                                {
                                    ckfile += "string " + itemc + ",";
                                }
                                index++;
                            }
                            ckfile = ckfile.TrimEnd(',');
                            ckfilec = ckfilec.TrimEnd(',');
                            ckfiled = ckfiled.TrimEnd('+');
                            checkstr.Append("\t\tpublic async Task<CommonResult> Check" + item.file.FirstCharToUpper() + "(" + ckfile + ", string loginUserCode, string Id = \"\")\n\t\t{");
                            checkstr.Append("\n\t\t\tvar tableName = TableAtributeUtil.GetTable<" + model.FirstCharToUpper() + ">();");
                            checkstr.Append("\n\t\t\tstring sql = string.Format(\"select cTime, Id from {0} where " + ckfileb + "and status<>-9 \", tableName, " + ckfilec + ");");
                            checkstr.Append("\n\t\t\treturn await baseApplication.CheckDataExists(BusinessType." + model + ",");
                            checkstr.Append("\n\t\t\tBusinessLogType.writeLogToDataBase, loginUserCode, sql, " + ckfiled + " + Id, \"检查" + module + "模块" + item.name + "是否存在\", Id);\n\t\t}\n\n");
                        }
                        else
                        {
                            checkstr.Append("\t\tpublic async Task<CommonResult> Check" + item.file.FirstCharToUpper() + "(string " + isonlys[0] + ", string loginUserCode, string Id = \"\")\n\t\t{");
                            checkstr.Append("\n\t\t\tvar tableName = TableAtributeUtil.GetTable<" + model.FirstCharToUpper() + ">();");
                            checkstr.Append("\n\t\t\tstring sql = string.Format(\"select cTime, Id from {0} where " + item.file + " = '{1}'and status<>-9 \", tableName, " + isonlys[0] + ");");
                            checkstr.Append("\n\t\t\treturn await baseApplication.CheckDataExists(BusinessType." + model + ",");
                            checkstr.Append("\n\t\t\tBusinessLogType.writeLogToDataBase, loginUserCode, sql, " + isonlys[0] + " + Id, \"检查" + module + "模块" + item.name + "是否存在\", Id);\n\t\t}\n\n");
                        }
                        cind++;
                    }
                    #endregion

                    #region 字段下拉查询动态值设置
                    StringBuilder querystr = new StringBuilder();
                    var havedt = false;
                    var havedtsql = string.Empty;
                    foreach (var query in generators)
                    {
                        if (query.querytype == 2 || query.querytype == 4 || query.querytype == 6)
                        {
                            havedt = true;
                            var sql = string.Empty;
                            if (!query.querystra.IsNull())
                            {
                                sql = query.querystra.Split('|')[0];
                            }
                            if (!query.querystrc.IsNull())
                            {
                                sql = query.querystrc.Split('|')[0];
                            }
                            var autovalue = string.Empty;
                            var querycon = string.Empty;
                            if (query.querytype == 6 && !string.IsNullOrEmpty(query.autovalue))
                            {
                                autovalue = "\n\t\t\t/// <param name=\"" + query.autovalue + "\"></param>";
                                querycon = "string " + query.autovalue + "";
                            }
                            querystr.Append("/// <summary>\n\t\t/// 获取" + query.name + "集合信息\n\t\t/// </summary>" + autovalue + "\n\t\t/// <returns></returns>\n");
                            querystr.Append("\t\tpublic async Task<CommonResult> Get" + query.file.FirstCharToUpper() + "List(" + querycon + ")\n\t\t{\n");
                            querystr.Append("\t\t\treturn await Task.Factory.StartNew(() =>\n\t\t\t{\n\t\t\t  CommonResult result = new CommonResult();\n");
                            querystr.Append("\t\t\t  var sql = \"" + sql + "\";\n\t\t\t  var dt = baseService.GetDataTable(sql,null,out var msg);\n");
                            querystr.Append("\t\t\t  result.msg = msg;\n\t\t\t  result.data = dt;\n\t\t\t  return result;\n\t\t\t});\n\t\t}\n");
                            if (!string.IsNullOrEmpty(query.querystra))
                            {
                                havedtsql = query.querystra;
                            }
                            if (!string.IsNullOrEmpty(query.querystrc))
                            {
                                havedtsql = query.querystrc;
                            }
                        }
                    }
                    if (havedt && string.IsNullOrEmpty(havedtsql))
                    {
                        result.msg = ImplementResult.ParameterException.GetRemark();
                        return result;
                    }
                    #endregion

                    #region 设置Excel表格导入数据
                    StringBuilder iptttmp = new StringBuilder();
                    if (generators.Any(o => o.isimport == true))
                    {
                        var importdata = generators.Where(o => o.isedit).OrderBy(o => o.editindex);
                        if (generators.Any(o => o.isonlyb != ""))
                        {
                            var wycklist = importdata.Where(o => o.isonly != "");
                            var ckfs = "status";
                            foreach (var itemck in wycklist)
                            {
                                foreach (var item in itemck.isonlyb.Split(','))
                                {
                                    ckfs += item + ",";
                                }
                            }
                            ckfs = ckfs.TrimEnd(',');
                            iptttmp.Append("var tableName = TableAtributeUtil.GetTable<" + model.FirstCharToUpper() + ">();\n\t\t\t");
                            iptttmp.Append("string sql =$\"select " + ckfs + " from {tableName} where status<>-9;\";\n\t\t\t");
                            iptttmp.Append("var listdt = baseService.GetDataTable(sql, null, out  msg);\n\t\t\t");
                        }
                        iptttmp.Append("var Index = 1;\n\t\t\tList<" + model.FirstCharToUpper() + "> addlist = new List<" + model.FirstCharToUpper() + ">();\n\t\t\t");
                        iptttmp.Append("foreach (DataRow data in dt.Rows)\n\t\t{\n\t\t\t");
                        iptttmp.Append("if (Index < " + generators.FirstOrDefault().exportstart + ")\n\t\t\t{\n\t\t\tIndex++;\n\t\t\tcontinue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\tIndex++;\n\t\t\t}\n\t\t\t");
                        var iindex = 0;
                        foreach (var item in importdata)
                        {
                            iptttmp.Append("var " + item.file + " = data.ItemArray[" + iindex + "].ToString(); // " + item.name + "\n\t\t\t");
                            if (iindex == 0)
                            {
                                if (!string.IsNullOrEmpty(item.importendstr))
                                {
                                    iptttmp.Append("if (" + item.file + ".Contains(\"" + item.importendstr + "\") || string.IsNullOrEmpty(" + item.file + "))\n\t\t\t{\n\t\t\t break;\n\t\t\t}\n");
                                }
                                else
                                {
                                    iptttmp.Append("if (string.IsNullOrEmpty(" + item.file + "))\n\t\t\t{\n\t\t\t break;\n\t\t\t}\n");
                                }
                            }
                            if (!string.IsNullOrEmpty(item.isonlyb))
                            {
                                StringBuilder fileq = new StringBuilder();
                                fileq.Append("status<>-9");
                                StringBuilder filer = new StringBuilder();
                                StringBuilder existd = new StringBuilder();
                                foreach (var itemb in item.isonlyb.Split(','))
                                {
                                    if (!string.IsNullOrEmpty(itemb))
                                    {
                                        fileq.Append(" and " + itemb + "='{" + itemb + "}'");
                                        existd.Append("" + itemb + ",");
                                        var filedes = generators.Where(o => o.file == itemb).Select(o => o.name).FirstOrDefault();
                                        filer.Append("" + filedes + "+");
                                    }
                                }
                                iptttmp.Append("var havedata = listdt.Select($\"" + fileq.ToString() + "\");\n\t\t\t");
                                iptttmp.Append("if (havedata.Length > 0)\n\t\t\t{\n\t\t\t msg = $\"第\" + Index + \"行，校验不通过：该" + filer.ToString().TrimEnd('+') + "数据【{" + existd.ToString().TrimEnd(',') + "}】已经存在;\";\n\t\t\t  msgsb.Append(msg);\n\t\t\t}\n\t\t\t");
                            }
                            if (iindex == importdata.Count() - 1)
                            {
                                var ida = 0;
                                foreach (var itemb in importdata)
                                {
                                    if (ida == 0)
                                    {
                                        iptttmp.Append("" + model.FirstCharToUpper() + " " + model + " = new " + model.FirstCharToUpper() + "()\n\t\t\t{\n\t\t\t");
                                    }
                                    if (ida == importdata.Count() - 1)
                                    {
                                        //if (itemb.fileType.Contains("int") || itemb.fileType.Contains("smallint") || itemb.fileType.Contains("tinyint"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToInt32(" + itemb.file + ")\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("decimal"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToDecimal(" + itemb.file + ")\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("double"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToDouble(" + itemb.file + ")\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("varchar"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=" + itemb.file + "\n\t\t\t");
                                        //}
                                        iptttmp.Append("" + itemb.file + "=" + itemb.file + "\n\t\t\t");
                                        iptttmp.Append("};\n\t\t\t");
                                    }
                                    else
                                    {
                                        //if (itemb.fileType.Contains("int") || itemb.fileType.Contains("smallint") || itemb.fileType.Contains("tinyint"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToInt32(" + itemb.file + "),\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("decimal"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToDecimal(" + itemb.file + "),\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("double"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=Convert.ToDouble(" + itemb.file + "),\n\t\t\t");
                                        //}
                                        //if (itemb.fileType.Contains("varchar"))
                                        //{
                                        //    iptttmp.Append("" + itemb.file + "=" + itemb.file + ",\n\t\t\t");
                                        //}
                                        iptttmp.Append("" + itemb.file + "=" + itemb.file + ",\n\t\t\t");
                                    }
                                    ida++;
                                }
                                iptttmp.Append("if (!" + model + ".ValidateModel(out msg))\n\t\t\t{\n\t\t\t msg = \"第\" + Index + \"行，校验不通过：\"+msg;\n\t\t\tmsgsb.Append(msg);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t addlist.Add(" + model + ");\n\t\t\t}\n\t\t\t}\n\t\t\t");
                                iptttmp.Append("if (!string.IsNullOrEmpty(msgsb.ToString()))\n\t\t\t{ \n\t\t\tbaseService.Insert(addlist, out msg); if (!string.IsNullOrEmpty(msg))\n\t\t\t{\n\t\t\tforeach (var item in addlist)\n\t\t\t{\n\t\t\tbaseService.Insert(item, out msg);\n\t\t\t}\n\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\tmsg = msgsb.ToString();\n\t\t\t}\n\t\t\t");
                            }
                            iindex++;
                        }
                    }
                    #endregion

                    #region 设置文件上传信息
                    StringBuilder uftmp = new StringBuilder();
                    var fulist = generators.Where(o => o.querytype == 11).OrderBy(o => o.editindex);
                    foreach (var item in fulist)
                    {
                        uftmp.Append("/// <summary>\n\t\t\t/// " + item.name + "附件上传\n\t\t\t/// </summary>\n\t\t\t/// <param name=\"files\"></param>\n\t\t\t");
                        uftmp.Append("/// <param name=\"path\"></param>\n\t\t\t/// <returns></returns>\n\t\t\t");
                        uftmp.Append("public async Task<CommonResult> UploadFile" + item.file.FirstCharToUpper() + "(IFormFileCollection files, string path)\n\t\t\t{\n\t\t\t");
                        uftmp.Append("return await baseApplication.UploadFile(files, path);\n\t\t\t}\n\t\t\t");
                    }
                    #endregion

                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }
                    string newjson = json.Replace("Template", model.FirstCharToUpper())
                    .Replace("模板", module)
                    .Replace("uftmp", uftmp.ToString())
                    .Replace("bstype", model)
                    .Replace("iptttmp", iptttmp.ToString())
                    .Replace("cktmp", checkstr.ToString())
                    .Replace("qstm", querystr.ToString());
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                        return result;
                    }
                    FileUtil.WriteFile(generatorpath + "\\" + routemodule, filename, newjson);
                }
                return result;
            });
        }

        /// <summary>
        /// 生成后台Export导出模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteExport(string file, string exportPath, string model, string module, List<Generator> generators)
        {
            return await Task.Factory.StartNew(() =>
            {
                CommonResult result = new CommonResult();
                model = model.Replace("`", "").Split('-')[1];
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }

                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                string generatorpath = newpath + "\\" + path[path.Length - 1].Replace(path[path.Length - 1], path[path.Length - 1] + ".Export");
                var filename = $"{model.FirstCharToUpper()}Export.cs";
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                    return result;
                }
                var routemodule = generators.FirstOrDefault().module.Split('-')[0];
                if (!FileUtil.Exists(generatorpath + "\\" + routemodule + "\\" + filename))
                {
                    StringBuilder exsb = new StringBuilder();
                    var exindex = 0;
                    var exceldata = generators.Where(o => o.istitle == true && o.isadditional == false).OrderBy(o => o.exportindex);
                    foreach (var item in exceldata)
                    {
                        if (string.Compare(item.file.ToLower(), "remark", true) == 0)
                        {
                            item.file = "Remark";
                        }
                        if (item.isadditional)
                        {
                            continue;
                        }
                        if (!item.exportselect)
                        {
                            exindex++;
                            exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + ");\n");
                            continue;
                        }
                        if (exindex == 0)
                        {
                            if (!string.IsNullOrEmpty(item.fileshow) || item.querytype==1)
                            {
                                var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystrb);
                                exsb.Append("List<GeneratorstaticCheck> " + item.file + "list = new List<GeneratorstaticCheck>();\n\t\t\t");
                                var ind = 0;
                                foreach (var itemb in pdata)
                                {
                                    exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                    ind++;
                                }
                                exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tvar new" + item.file + " = " + item.file + "list.Where(o => o.value == item." + item.file + ".ToString()).FirstOrDefault().label;\n\t\t\tcell.SetCellValue(new" + item.file + ");\n");
                            }
                            else if (item.querytype == 3)
                            {
                                exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + ");\n");
                            }
                            else
                            {
                                if (item.querytype == 9)
                                {
                                    var ind = 0;
                                    var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystre);
                                    exsb.Append("List<GeneratorstaticCheck> " + item.file + "list = new List<GeneratorstaticCheck>();\n\t\t\t");
                                    foreach (var itemb in pdata)
                                    {
                                        exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                        ind++;
                                    }
                                    exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tvar new" + item.file + " = " + item.file + "list.Where(o => o.value == item." + item.file + ".ToString()).FirstOrDefault().label;\n\t\t\tcell.SetCellValue(new" + item.file + ");\n");
                                }
                                else
                                {
                                    exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + ");\n");
                                }
                            }
                        }
                        else
                        {
                            if (string.Compare(item.file, "status", true) == 0)
                            {
                                exsb.Append("\t\t//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + " == 1 ? \"启用\" : \"停用\");\n");
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(item.fileshow) )
                                {
                                    exsb.Append("List<GeneratorstaticCheck> " + item.file + "list = new List<GeneratorstaticCheck>();\n\t\t\t");
                                    var ind = 0;
                                    if(item.querytype==1)
                                    {
                                        var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystrb);
                                        foreach (var itemb in pdata)
                                        {
                                            exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                            ind++;
                                        }
                                    }
                                    else if (item.querytype == 8)
                                    {
                                        var pdata = JsonUtil.UnRendResults<Singlechoice>(item.querystrd);
                                        foreach (var itemb in pdata)
                                        {
                                            exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.title + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                            ind++;
                                        }
                                    }
                                    else
                                    {
                                        var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystrb);
                                        foreach (var itemb in pdata)
                                        {
                                            exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                            ind++;
                                        }
                                    }
                                    exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tvar new" + item.file + " = " + item.file + "list.Where(o => o.value == item." + item.file + ".ToString()).FirstOrDefault().label;\n\t\t\tcell.SetCellValue(new" + item.file + ");\n");
                                }
                                else
                                {
                                    if (item.querytype == 1)
                                    {
                                        exsb.Append("List<GeneratorstaticCheck> " + item.file + "list = new List<GeneratorstaticCheck>();\n\t\t\t");
                                        var ind = 0;
                                        var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystrb);
                                        foreach (var itemb in pdata)
                                        {
                                            exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                            ind++;
                                        }
                                        exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tvar new" + item.file + " = " + item.file + "list.Where(o => o.value == item." + item.file + ".ToString()).FirstOrDefault().label;\n\t\t\tcell.SetCellValue(new" + item.file + ");\n");
                                    }
                                    else if (item.querytype == 3)
                                    {
                                        exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + ");\n");
                                    }
                                    else if (item.querytype == 9)
                                    {
                                        var ind = 0;
                                        var pdata = JsonUtil.UnRendResults<GeneratorstaticCheck>(item.querystre);
                                        exsb.Append("List<GeneratorstaticCheck> " + item.file + "list = new List<GeneratorstaticCheck>();\n\t\t\t");
                                        foreach (var itemb in pdata)
                                        {
                                            exsb.Append("GeneratorstaticCheck " + item.file + "" + ind + " = new GeneratorstaticCheck() { label =  \"" + itemb.label + "\", value = \"" + itemb.value + "\" };\n\t\t\t" + item.file + "list.Add(" + item.file + "" + ind + ");\n\t\t\t");
                                            ind++;
                                        }
                                        exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tvar new" + item.file + " = " + item.file + "list.Where(o => o.value == item." + item.file + ".ToString()).FirstOrDefault().label;\n\t\t\tcell.SetCellValue(new" + item.file + ");\n");
                                    }
                                    else
                                    {
                                        exsb.Append("//" + item.name + "\n\t\tcell = row.CreateCell(" + exindex + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item." + item.file + ");\n");
                                    }
                                }
                            }
                        }
                        exindex++;
                    }
                    if (exceldata.Any(o => o.isexportdefault == true) && exceldata.Count(o => o.exporttemplate == "") == 0)
                    {
                        exsb.Append("\t\t\t//创建时间\n\t\tcell = row.CreateCell(" + (exindex) + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item.cTime.ToString(\"yyyy-MM-dd HH:mm:ss\"));\n");
                        exsb.Append("\t\t\t//更新时间\n\t\tcell = row.CreateCell(" + (exindex + 1) + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item.uTime?.ToString(\"yyyy-MM-dd HH:mm:ss\")== \"0001-01-01 00:00:00\"?\"无\" : item.uTime?.ToString(\"yyyy-MM-dd HH:mm:ss\"));\n");
                        exsb.Append("\t\t\t//描述\n\t\tcell = row.CreateCell(" + (exindex + 2) + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item.Remark);\n");
                        exsb.Append("\t\t\t//状态\n\t\tcell = row.CreateCell(" + (exindex + 3) + ");\n\t\t\tcell.CellStyle = TextSytle;\n\t\t\tcell.SetCellValue(item.status == 1 ? \"启用\" : \"停用\");\n");
                    }
                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }
                    var isdate = true;
                    if (generators.Count(o => o.exporttemplate == "") == 0)
                    {
                        isdate = false;
                    }
                    string newjson = json.Replace("Template", model.FirstCharToUpper()).
                    Replace("模板", module).
                    Replace("exportmp", exsb.ToString()).
                    Replace("istart", (generators[0].exportstart-1).ToString())
                    .Replace("isdate", isdate.ToString().ToLower());
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        result.msg = ImplementResult.DirectoryNotExist.GetRemark();
                        return result;
                    }
                    FileUtil.WriteFile(generatorpath + "\\" + routemodule, filename, newjson);
                }
                return result;
            });
        }

        /// <summary>
        /// 生成前端Model模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="directoryname">所属模块目录名称</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <param name="type">1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteModel(string file, string exportPath, string model, string module, string directoryname, IMySqlSugarService service, List<Generator> generators,int type)
        {
            return await Task.Factory.StartNew(() =>
            {
                model = model.Replace("`", "").Split('-')[1];
                model = model.ToLower();
                CommonResult result = new CommonResult();
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull() || directoryname.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                var generatorpath = string.Empty;
                if (type == 1)
                {
                    generatorpath = newpath + "webng\\src\\app\\domain\\" + directoryname;
                }
                if (type == 2)
                {
                    generatorpath = newpath + "wb13\\src\\app\\domain\\" + directoryname;
                }
                var filename = $"{model}.model.ts";
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    FileUtil.CreateDirectory(generatorpath);
                }
                if (!FileUtil.Exists(generatorpath + "\\" + filename))
                {
                    var imtmp = "";//导入属性设置
                    if (generators[0].isimport)
                    {
                        imtmp = "\tthis.ImportApi = 'api/" + model.FirstCharToUpper() + "/ImportExcel';\n\t\tthis.DownApi = 'down/" + module + ".xls';";
                    }

                    #region 设置列表所有字段信息
                    StringBuilder entitymodel = new StringBuilder(); // 字段定义
                    var eindex = 0;
                    foreach (var item in generators)
                    {
                        if (item.isadditional)
                        {
                            continue;
                        }
                        if (eindex == 0)
                        {
                            entitymodel.Append("public " + item.file + "?: string;\n");
                        }
                        else
                        {
                            if (eindex == generators.Count() - 1)
                            {
                                entitymodel.Append("\tpublic " + item.file + "?: string;");
                            }
                            else
                            {
                                entitymodel.Append("\tpublic " + item.file + "?: string;\n");
                            }
                        }
                        eindex++;
                    }
                    #endregion

                    #region 设置列表显示字段信息
                    StringBuilder showtitletemplate = new StringBuilder(); //字段显示定义
                    var titlelist = generators.Where(o => o.istitle == true && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.titleindex); //显示字段
                    var ishb = generators.Any(o => o.isadditional == true);
                    var titleindex = 0;
                    if (!ishb)
                    {
                        foreach (var item in titlelist)
                        {
                            if (titleindex == 0)
                            {
                                showtitletemplate.Append("{ label: '" + item.name.Split(' ')[0] + "', width: '100px' },\n");
                            }
                            else
                            {
                                if (titleindex == titlelist.Count() - 1)
                                {
                                    showtitletemplate.Append("\t\t\t{ label: '" + item.name.Split(' ')[0] + "', width: '100px' },");
                                }
                                else
                                {
                                    showtitletemplate.Append("\t\t\t{ label: '" + item.name.Split(' ')[0] + "', width: '100px' },\n");
                                }
                            }
                            titleindex++;
                        }
                        if (titlelist.Count() <= 5)
                        {
                            showtitletemplate.Append("\n\t\t\t{ label: '创建时间', width: '120px' },\n");
                            showtitletemplate.Append("\t\t\t{ label: '更新时间', width: '120px' },\n");
                            showtitletemplate.Append("\t\t\t{ label: '描述', width: '140px' },\n");
                            showtitletemplate.Append("\t\t\t{ label: '停用?', width: '60px' },");
                        }
                    }
                    #endregion

                    StringBuilder validationmsgtemplate = new StringBuilder(); //错误字段提示定义

                    #region 设置为空字段信息
                    var nulllist = generators.Where(o => o.isnullb == false && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.editindex); //为空字段
                    var nullcount = generators.Count(o => o.isnullb == false && o.file.ToUpper() != "Id".ToUpper());
                    var nullindex = 0;
                    foreach (var item in nulllist)
                    {
                        var checkstr = string.Empty;
                        if (!string.IsNullOrEmpty(item.isonly))
                        {
                            checkstr = "\t\t" + item.file.FirstCharToUpper() + "YZ:\t'该" + item.name + "信息已经存在，请检查！'\n\t\t";
                        }
                        if (nullcount == 1)
                        {
                            if (!string.IsNullOrEmpty(item.format))
                            {
                                validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\t pattern: '" + item.format.Split('=')[0] + "', \n\t\t " + checkstr + "},");
                            }
                        }
                        else
                        {
                            if (nullindex == nullcount - 1)
                            {
                                if (!string.IsNullOrEmpty(item.format))
                                {
                                    validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\t pattern: '" + item.format.Split('=')[0] + "', \n\t\t " + checkstr + "},");
                                }
                            }
                            else
                            {
                                if (nullindex == 0)
                                {
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\t pattern: '" + item.format.Split('=')[0] + "', \n\t\t " + checkstr + "},");
                                    }
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\t pattern: '" + item.format.Split('=')[0] + "', \n\t\t " + checkstr + "},");
                                    }
                                }
                            }
                        }
                        nullindex++;
                    }
                    #endregion

                    #region 设置不为空字段信息
                    StringBuilder formerrorstemplate = new StringBuilder(); //错误字段定义
                    var nonulllist = generators.Where(o => o.isnullb == true && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.editindex); //不为空字段
                    var nonullcount = generators.Count(o => o.isnullb == true && o.file.ToUpper() != "Id".ToUpper());
                    var notindex = 0;
                    foreach (var item in nonulllist)
                    {
                        var checkstr = string.Empty;
                        if (!string.IsNullOrEmpty(item.isonly))
                        {
                            checkstr = "\t\t" + item.file.FirstCharToUpper() + "YZ:\t'该" + item.name + "信息已经存在，请检查！'\n\t\t";
                        }
                        if (!string.IsNullOrEmpty(item.notequal))
                        {
                            var notequal = string.Empty;
                            var notequallist = item.notequal.Split(',');
                            foreach (var itemb in notequallist)
                            {
                                notequal += itemb + ",";
                            }
                            notequal = "不能填：" + notequal.TrimEnd(',');
                            if (string.IsNullOrEmpty(checkstr))
                            {
                                checkstr = "\t\t" + item.file.FirstCharToUpper() + "YZB:'" + notequal + "'";
                            }
                            else
                            {
                                checkstr += ",\n\t\t" + item.file.FirstCharToUpper() + "YZB:'" + notequal + "'";
                            }
                        }
                        if (!string.IsNullOrEmpty(item.checkdata))
                        {
                            var positiveminmax = string.Empty;
                            if (item.checktype == 2)
                            {
                                positiveminmax = "请输入" + item.checkdata.Split(',')[0] + "-" + item.checkdata.Split(',')[1] + "之间的正整数";
                            }
                            if (item.checktype == 3)
                            {
                                var xxd = item.checkdata.Split(',')[1].Split('|');
                                if (xxd.Length == 2)
                                {
                                    positiveminmax = "请输入" + item.checkdata.Split(',')[0] + "-" + xxd[0] + "小数位数为" + xxd[1] + "位的有效数字";
                                }
                                else
                                {
                                    positiveminmax = "请输入" + item.checkdata.Split(',')[0] + "-" + item.checkdata.Split(',')[1] + "之间的数值";
                                }
                            }
                            if (string.IsNullOrEmpty(checkstr))
                            {
                                checkstr = "\t\t" + item.file.FirstCharToUpper() + "YZC:'" + positiveminmax + "'";
                            }
                            else
                            {
                                checkstr += ",\n\t\t" + item.file.FirstCharToUpper() + "YZC:'" + positiveminmax + "'";
                            }
                        }
                        if (nonullcount == 1)
                        {
                            formerrorstemplate.Append("" + item.file + ": '',");
                            if (!string.IsNullOrEmpty(item.format))
                            {
                                validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\trequired: '不能为空', \n\t\t\t\tpattern: '" + item.format.Split('=')[0] + "',\n\t\t " + checkstr + " },");
                            }
                            else
                            {
                                validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\t required: '不能为空', \n\t\t " + checkstr + "},");
                            }
                        }
                        else
                        {
                            if (notindex == nonullcount - 1)
                            {
                                formerrorstemplate.Append("\t\t\t" + item.file + ": '',");
                                if (!string.IsNullOrEmpty(item.format))
                                {
                                    validationmsgtemplate.Append("\t\t\t" + item.file + ": {\n\t\t\t\trequired: '不能为空', \n\t\t\t\t pattern: '" + item.format.Split('=')[0] + "',\n\t\t " + checkstr + " },");
                                }
                                else
                                {
                                    validationmsgtemplate.Append("\t\t\t" + item.file + ": {\n\t\t\t\trequired: '不能为空', \n\t\t\t " + checkstr + "},");
                                }
                            }
                            else
                            {
                                if (notindex == 0)
                                {
                                    formerrorstemplate.Append("" + item.file + ": '',\n");
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\trequired: '不能为空', \n\t\t\t\tpattern: '" + item.format.Split('=')[0] + "',\n\t\t " + checkstr + "},\n");
                                    }
                                    else
                                    {
                                        validationmsgtemplate.Append("" + item.file + ": {\n\t\t\t\trequired: '不能为空', \n\t\t\t " + checkstr + "},\n");
                                    }
                                }
                                else
                                {
                                    formerrorstemplate.Append("\t\t\t" + item.file + ": '',\n");
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validationmsgtemplate.Append("\t\t\t" + item.file + ": {\n\t\t\t\trequired: '不能为空',\n\t\t\t\tpattern: '" + item.format.Split('=')[0] + "',\n\t\t " + checkstr + "},\n");
                                    }
                                    else
                                    {
                                        validationmsgtemplate.Append("\t\t\t" + item.file + ": {\n\t\t\t\trequired: '不能为空',\n\t\t\t " + checkstr + "},\n");
                                    }
                                }
                            }
                        }
                        notindex++;
                    }
                    #endregion

                    #region 设置字段验证信息
                    StringBuilder validateformtemplate = new StringBuilder(); // 字段验证定义
                    StringBuilder ckpar = new StringBuilder();//字段验证（正整数，数值区间）
                    var findex = 0;
                    var writecount = generators.Count(o => o.file.ToUpper() != "Remark".ToUpper() && o.file.ToUpper() != "status".ToUpper() && o.file.ToUpper() != "Id".ToUpper() && o.file.ToUpper() != "ctime".ToUpper() && o.file.ToUpper() != "utime".ToUpper());
                    foreach (var item in generators)
                    {
                        if (string.Compare(item.file.ToUpper(), "Remark".ToUpper(), true) != 0 && string.Compare(item.file.ToUpper(), "status".ToUpper(), true) != 0 &&
                        string.Compare(item.file.ToUpper(), "Id".ToUpper(), true) != 0 && string.Compare(item.file.ToUpper(), "ctime".ToUpper(), true) != 0 &&
                        string.Compare(item.file.ToUpper(), "utime".ToUpper(), true) != 0)
                        {
                            if (item.isadditional)
                            {
                                continue;
                            }
                            var ckf = string.Empty;
                            if (!string.IsNullOrEmpty(item.isonly) || !string.IsNullOrEmpty(item.notequal) || !string.IsNullOrEmpty(item.checkdata))
                            {
                                ckf = ", [this." + item.file.FirstCharToUpper() + "Check]";
                            }
                            var firsthh = "";
                            if (generators.Count > 1)
                            {
                                firsthh = "\n";
                            }
                            if (findex == 0)
                            {
                                if (item.isnullb)
                                {
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validateformtemplate.Append("" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required,\n\tValidators.pattern(" + item.format.Split('=')[1].Replace("%",@"\") + ")]" + ckf + "],");
                                    }
                                    else
                                    {
                                        validateformtemplate.Append("" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required]" + ckf + "],");
                                    }
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(item.format))
                                    {
                                        validateformtemplate.Append("" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ",[Validators.pattern(" + item.format.Split('=')[1].Replace("%", @"\") + ")]" + ckf + "],");
                                    }
                                    else
                                    {
                                        validateformtemplate.Append("" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ",[]" + ckf + "]" + ckf + ",");
                                    }
                                }
                            }
                            else
                            {
                                if (findex == writecount - 1)
                                {
                                    if (item.isnullb)
                                    {
                                        if (!string.IsNullOrEmpty(item.format))
                                        {
                                            validateformtemplate.Append("\n\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required, \n\tValidators.pattern(" + item.format.Split('=')[1].Replace("%", @"\") + ")]" + ckf + "],");
                                        }
                                        else
                                        {
                                            validateformtemplate.Append("\n\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required]" + ckf + "],");
                                        }
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(item.format))
                                        {
                                            validateformtemplate.Append("\n\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ",[Validators.pattern(" + item.format.Split('=')[1].Replace("%", @"\") + ")]" + ckf + "],");
                                        }
                                        else
                                        {
                                            validateformtemplate.Append("\n\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ",[]" + ckf + "],");
                                        }
                                    }

                                }
                                else
                                {
                                    if (item.isnullb)
                                    {
                                        if (!string.IsNullOrEmpty(item.format))
                                        {
                                            validateformtemplate.Append("" + firsthh + "\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required, \n\tValidators.pattern(" + item.format.Split('=')[1].Replace("%", @"\") + ")]" + ckf + "],");
                                        }
                                        else
                                        {
                                            validateformtemplate.Append("" + firsthh + "\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.required]" + ckf + "],");
                                        }
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(item.format))
                                        {
                                            validateformtemplate.Append("" + firsthh + "\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ", [Validators.pattern(" + item.format.Split('=')[1].Replace("%", @"\") + ")]" + ckf + "],");
                                        }
                                        else
                                        {
                                            validateformtemplate.Append("" + firsthh + "\t\t\t\t" + item.file + ": [selectEditData === undefined ? this." + item.file + " : selectEditData." + item.file + ",[]" + ckf + "],");
                                        }
                                    }
                                }
                            }
                            findex++;
                        }
                    }
                    #endregion

                    #region 设置字段校验信息
                    StringBuilder checkstrb = new StringBuilder();
                    var checklist = generators.Where(o => o.isonly != "" || !string.IsNullOrEmpty(o.notequal) || !string.IsNullOrEmpty(o.checkdata) || !string.IsNullOrEmpty(o.nosame)).OrderBy(o => o.editindex);
                    var cind = 0;
                    foreach (var item in checklist)
                    {
                        var url = "''"; // 唯一数据校验URL
                        var isonlyyz = "null";//唯一校验函数
                        var wyfile = "null";//唯一校验字段
                        if (!string.IsNullOrEmpty(item.isonly))
                        {
                            url = "'api/" + model.FirstCharToUpper() + "/Check" + item.file.FirstCharToUpper() + "'";
                            wyfile = "() => {\n\t\t\tconst Id = this.validateForm.controls.Id.value;\n";
                            var cks = item.isonly.Split(',');
                            var fis = string.Empty;
                            if (cks.Length > 1)
                            {
                                foreach (var itemb in cks)
                                {
                                    fis += "," + itemb;
                                    wyfile += "\t\t\tconst " + itemb + " = this.validateForm.controls." + itemb + ".value;\n";
                                }
                            }
                            else
                            {
                                fis = "," + cks[0] + "";
                                wyfile += "\t\t\tconst " + cks[0] + " = this.validateForm.controls." + cks[0] + ".value;\n";
                            }
                            wyfile += "\t\t\tconst data = { Id " + fis + "};\n\t\t\treturn data;\n\t\t}";
                            isonlyyz = " (result:any) => {\n\t\t\tresult.next({ error: true, " + item.file.FirstCharToUpper() + "YZ: true });\n";
                            isonlyyz += "\t\t\tconst messages = this.validationMessages." + item.file + ";\n\t\t\tthis.formErrors." + item.file + " = '';\n";
                            isonlyyz += "\t\t\tthis.formErrors." + item.file + " += messages." + item.file.FirstCharToUpper() + "YZ;\n\t\t\t }";
                        }
                        var notequal = item.notequal; // 不等于
                        notequal = "'" + notequal + "'";
                        var positive = item.checktype == 2 ? item.checkdata : "";//正整数区间
                        positive = "'" + positive + "'";
                        var minmax = item.checktype == 3 ? item.checkdata : "";//数值最小最大值区间
                        minmax = "'" + minmax + "'";
                        var notequalyz = "null"; // 不等于验证
                        var positivemainmax = "null";//正整数最小最大值区间验证
                        if (!string.IsNullOrEmpty(item.notequal))
                        {
                            notequalyz = " (resultb:any) => {\n\t\t\tresultb.next({ error: true, " + item.file.FirstCharToUpper() + "YZB: true });\n";
                            notequalyz += "\t\t\tconst messages = this.validationMessages." + item.file + ";\n\t\t\tthis.formErrors." + item.file + " = '';\n";
                            notequalyz += "\t\t\tthis.formErrors." + item.file + " += messages." + item.file.FirstCharToUpper() + "YZB;\n\t\t\t }";
                        }
                        if (!string.IsNullOrEmpty(item.checkdata))
                        {
                            positivemainmax = " (resultc:any) => {\n\t\t\tresultc.next({ error: true, " + item.file.FirstCharToUpper() + "YZC: true });\n";
                            positivemainmax += "\t\t\tconst messages = this.validationMessages." + item.file + ";\n\t\t\tthis.formErrors." + item.file + " = '';\n";
                            positivemainmax += "\t\t\tthis.formErrors." + item.file + " += messages." + item.file.FirstCharToUpper() + "YZC;\n\t\t\t }";
                        }
                        var nosameyz = "null"; // 不相同的两个字段校验
                        var nosame = item.nosame; // 不相同的两个字段校验
                        nosame = "'" + nosame + "'";
                        if (!string.IsNullOrEmpty(item.nosame))
                        {
                            nosameyz = " (resultb:any) => {\n\t\t\tresultb.next({ error: true, " + item.file.FirstCharToUpper() + "YZB: true });\n";
                            nosameyz += "\t\t\tconst messages = this.validationMessages." + item.file + ";\n\t\t\tthis.formErrors." + item.file + " = '';\n";
                            nosameyz += "\t\t\tthis.formErrors." + item.file + " += messages." + item.file.FirstCharToUpper() + "YZB;\n\t\t\t }";
                        }
                        checkstrb.Append("" + item.file.FirstCharToUpper() + "Check = (control: FormControl) => {\n");
                        checkstrb.Append("\t\t\treturn this.Datavalidator(this.isloadDone, " + notequal + "," + positive + "," + minmax + ",control, " + url + "," + wyfile + "," + isonlyyz + "," + notequalyz + "," + positivemainmax + "," + nosame + "," + nosameyz + ");\n\t\t}\n\n");
                        cind++;
                    }
                    #endregion;

                    #region 设置新增编辑界面宽度
                    var nzWidthtmp = "";
                    if (generators.Any(o => o.isedit))
                    {
                        nzWidthtmp = "\tthis.nzWidth\t=\t'" + generators[0].editWidth + "%';";
                    }
                    #endregion

                    #region 设置编辑界面描述字段信息
                    var editdsc = string.Empty;
                    var editdsclist = generators.Where(o => o.iseditdsc);
                    var edindex = 0;
                    foreach (var item in editdsclist)
                    {
                        if (editdsclist.Count() == 1)
                        {
                            editdsc = "data." + item.file;
                        }
                        else
                        {
                            if (edindex == editdsclist.Count() - 1)
                            {
                                editdsc += "data." + item.file;
                            }
                            else
                            {
                                editdsc += "data." + item.file + " + '-' + ";
                            }
                        }
                        edindex++;
                    }
                    editdsc = "return " + editdsc + ";";
                    #endregion

                    #region 设置查询字段信息
                    var qform = string.Empty;
                    var querylist = generators.Where(o => (o.isquery == true || o.isadd == true) && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.queryindex); //查询字段
                    StringBuilder qlist = new StringBuilder();
                    var qindex = 0;
                    if (!generators.Any(o => o.isquerymore))
                    {
                        foreach (var item in querylist)
                        {
                            if (!item.isquery)
                                continue;

                            if (querylist.Count() == 1)
                            {
                                if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                    item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                    item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.defaultvalue))
                                {
                                    qlist.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.defaultvalue) + " } ");
                                }
                                else
                                {
                                    qlist.Append("{ name: '" + item.file + "', value: '" + item.defaultvalue + "' } ");
                                }
                            }
                            else
                            {
                                if (qindex == querylist.Count() - 1)
                                {
                                    if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                   item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                   item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.defaultvalue))
                                    {
                                        qlist.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.defaultvalue) + " } ");
                                    }
                                    else
                                    {
                                        qlist.Append("{ name: '" + item.file + "', value: '" + item.defaultvalue + "' } ");
                                    }
                                }
                                else
                                {
                                    if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                     item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                     item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.defaultvalue))
                                    {
                                        qlist.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.defaultvalue) + " }, ");
                                    }
                                    else
                                    {
                                        qlist.Append("{ name: '" + item.file + "', value: '" + item.defaultvalue + "' }, ");
                                    }
                                }
                            }
                            qindex++;
                        }
                    }
                    if (!string.IsNullOrEmpty(qlist.ToString()))
                    {
                        qform = "return [" + qlist.ToString().Trim().TrimEnd(',') + "];";
                    }
                    else
                    {
                        qform = "return [ ];";
                    }
                    #endregion

                    #region 设置编辑界面初始化字段信息
                    var iform = string.Empty;
                    var iformlist = generators.Where(o => o.iseditinit == true && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.isedit); //查询字段
                    StringBuilder iformstr = new StringBuilder();
                    var iindex = 0;
                    foreach (var item in iformlist)
                    {
                        if (iformlist.Count() == 1)
                        {
                            if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.editinitvalue))
                            {
                                iformstr.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.editinitvalue) + " } ");
                            }
                            else
                            {
                                iformstr.Append("{ name: '" + item.file + "', value: '" + item.editinitvalue + "' } ");
                            }
                        }
                        else
                        {
                            if (iindex == iformlist.Count() - 1)
                            {
                                if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                 item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                 item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.editinitvalue))
                                {
                                    iformstr.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.editinitvalue) + " } ");
                                }
                                else
                                {
                                    iformstr.Append("{ name: '" + item.file + "', value: '" + item.editinitvalue + "' } ");
                                }
                            }
                            else
                            {
                                if ((item.fileType.Contains("int") || item.fileType.Contains("decimal") ||
                                item.fileType.Contains("smallint") || item.fileType.Contains("tinyint") ||
                                item.fileType.Contains("double")) && !string.IsNullOrEmpty(item.editinitvalue))
                                {
                                    iformstr.Append("{ name: '" + item.file + "', value: " + Convert.ToDouble(item.editinitvalue) + " }, ");
                                }
                                else
                                {
                                    iformstr.Append("{ name: '" + item.file + "', value: '" + item.editinitvalue + "' }, ");
                                }
                            }
                        }
                        iindex++;
                    }
                    if (!string.IsNullOrEmpty(iformstr.ToString()))
                    {
                        iform = "return [" + iformstr.ToString() + "];";
                    }
                    else
                    {
                        iform = "return [];";
                    }
                    #endregion

                    #region 设置下拉数据集信息
                    string qtlist = string.Empty;//下拉、单选框、复选框数据集
                    StringBuilder qdtmp = new StringBuilder();// 下拉、单选框、复选框数据集初始化
                    foreach (var item in querylist)
                    {
                        if (item.querytype == 1 || item.querytype == 3 || item.querytype == 5 || item.querytype == 12)
                        {
                            if (qindex == 0)
                            {
                                qtlist = "public" + item.file.FirstCharToUpper() + "List: any[] = [];\n";
                                if (item.querytype != 5) //下拉数据集获取方法
                                {
                                    if (item.querytype == 12)
                                    {
                                        qdtmp.Append("this." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrdd + ";");
                                    }
                                    else
                                    {
                                        qdtmp.Append("this." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrb + ";");
                                    }
                                }
                                else
                                {
                                    qdtmp.Append("this." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrc + ";");
                                }
                            }
                            else
                            {
                                qtlist += "public\t" + item.file.FirstCharToUpper() + "List: any[] = [];\n";
                                if (item.querytype != 5) //下拉数据集获取方法
                                {
                                    if (item.querytype == 12)
                                    {
                                        qdtmp.Append("\n\t\tthis." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrdd + ";\n\t\t");
                                    }
                                    else
                                    {
                                        qdtmp.Append("\n\t\tthis." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrb + ";\n\t\t");
                                    }
                                }
                                else
                                {
                                    qdtmp.Append("\n\t\tthis." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrc + ";\n\t\t");
                                }
                            }
                        }
                        qindex++;
                    }
                    #endregion

                    #region 设置单选框、复选框数据集信息
                    var havedflist = generators.Where(o => o.querytype == 8 || o.querytype == 9);
                    if (havedflist.Count() > 0)
                    {
                        foreach (var item in havedflist)
                        {
                            qtlist += "public\t" + item.file.FirstCharToUpper() + "List: any[] = [];\n";
                            if (item.querytype == 8)
                            {
                                qdtmp.Append("\n\t\tthis." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystrd + ";\n\t\t");
                            }
                            if (item.querytype == 9)
                            {
                                qdtmp.Append("\n\t\tthis." + item.file.FirstCharToUpper() + "List\t=\t" + item.querystre + ";\n\t\t");
                            }
                        }
                    }

                    #endregion

                    #region 设置文件上传信息
                    StringBuilder uftmpa = new StringBuilder();
                    StringBuilder uftmpb = new StringBuilder();
                    var fulist = generators.Where(o => o.querytype == 10).OrderBy(o => o.editindex);
                    foreach (var item in fulist)
                    {
                        uftmpa.Append("public " + item.file + "Api = '';\n\t\t\t");
                        uftmpb.Append("this." + item.file + "Api = 'api/" + model.FirstCharToUpper() + "/Upload" + item.file.FirstCharToUpper() + "';\n\t\t\t");
                    }
                    #endregion

                    #region 设置文件预览信息
                    StringBuilder yltmp = new StringBuilder();
                    StringBuilder ylapitmp = new StringBuilder();
                    var havepreview = generators.Where(o => o.querytype == 11);
                    if (havepreview.Count() > 0)
                    {
                        foreach (var item in havepreview)
                        {
                            yltmp.Append("public uploadApi"+item.file.FirstCharToUpper()+"?: string;\n\t\t");
                            ylapitmp.Append("this.uploadApi"+item.file.FirstCharToUpper()+ " = 'api/"+model.FirstCharToUpper()+"/UploadFile" + item.file.FirstCharToUpper() + " ';\n\t\t");
                        }
                    }
                    #endregion

                    #region 设置编辑框是否内容自适应高度
                    string ismhauto = "";
                    if(generators.Count(o=>o.isadd && !o.isadditional)> 14)
                    {
                        ismhauto = " this.modalheightauto = false;";
                    }
                    #endregion

                    var entityname = model.FirstCharToUpper();
                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }

                    var tmpover = string.Empty;
                    if (type == 2)
                    {
                        tmpover = "override";
    }
                    string newjson = json.Replace("template", entityname).Replace("模板", module)
                    .Replace("tmpover", tmpover)
                    .Replace("ismhauto", ismhauto)
                    .Replace("uftmpa", uftmpa.ToString())
                    .Replace("uftmpb", uftmpb.ToString())
                    .Replace("entitymodel", entitymodel.ToString())
                    .Replace("formerrtmp", formerrorstemplate.ToString())
                    .Replace("vmtmp", validationmsgtemplate.ToString())
                    .Replace("vmformtmp", validateformtemplate.ToString())
                    .Replace("sttmp", showtitletemplate.ToString())
                    .Replace("nzWidthtmp", nzWidthtmp)
                    .Replace("editdsc", editdsc)
                    .Replace("qform", qform)
                    .Replace("imtmp", imtmp)
                    .Replace("iform", iform)
                    .Replace("qtlist", qtlist)
                    .Replace("yltmp", yltmp.ToString())
                    .Replace("ylapitmp", ylapitmp.ToString())
                    .Replace("qdtmp", qdtmp.ToString())
                    .Replace("ckpar", ckpar.ToString())
                    .Replace("cktmp", checkstrb.ToString());
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        FileUtil.CreateDirectory(generatorpath);
                    }
                    FileUtil.WriteFile(generatorpath, filename, newjson);
                }
                return result;
            });
        }

        /// <summary>
        /// 生成前端Scss模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="directoryname">所属模块目录名称</param>
        /// <param name="isedit">是否生成编辑页面样式</param>
        /// <param name="service"></param>
        /// <param name="type">1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteScss(string file, string exportPath, string model, string directoryname, bool isedit, IMySqlSugarService service,int type)
        {
            return await Task.Factory.StartNew(() =>
            {
                model = model.Replace("`", "").Split('-')[1];
                model = model.ToLower();
                CommonResult result = new CommonResult();
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || directoryname.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                var entityname = model.FirstCharToUpper();
                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                string json = FileUtil.ReadFile(file);
                var generatorpath = string.Empty;
                if (type == 1)
                {
                    generatorpath = newpath + "webng\\src\\app\\modules\\" + directoryname + "\\" + model;
                }
                if (type == 2)
                {
                    generatorpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname + "\\" + model;
                }

                var filename = $"{model}.component.scss";
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    FileUtil.CreateDirectory(generatorpath);
                }
                if (!FileUtil.Exists(generatorpath  + "\\" + filename))
                {
                    FileUtil.WriteFile(generatorpath, filename, json);
                    if (isedit)
                    {
                        filename = $"add\\add.component.scss";
                        if (!FileUtil.ExistsDir(generatorpath + "\\add"))
                        {
                            FileUtil.CreateDirectory(generatorpath + "\\add");
                        }
                        if (!FileUtil.Exists(generatorpath + "\\" + filename))
                        {
                            FileUtil.WriteFile(generatorpath, filename, json);
                        }
                    }
                }
                return result;
            });
        }

        /// <summary>
        /// 生成前端Index模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="directoryname">所属模块目录名称</param>
        /// <param name="isedit">是否生成编辑页面组件</param>
        /// <param name="fileNameIndexAdd">编辑页面组件模板路径</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <param name="type">1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteIndex(string file, string exportPath, string model, string directoryname, bool isedit, string fileNameIndexAdd, IMySqlSugarService service, List<Generator> generators,int type)
        {
            return await Task.Factory.StartNew(() =>
            {
                model = model.Replace("`", "").Split('-')[1];
                model = model.ToLower();
                CommonResult result = new CommonResult();
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || directoryname.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }
                var entityname = model.FirstCharToUpper();
                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                var generatorpath = string.Empty;
                if (type == 1)
                {
                    generatorpath = newpath + "webng\\src\\app\\modules\\" + directoryname + "\\" + model;
                }
                if (type == 2)
                {
                    generatorpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname + "\\" + model;
                }

                string json = FileUtil.ReadFile(file);
                json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                var filename = $"index.ts";
                if (!msga.IsNull())
                {
                    result.msg = ImplementResult.Templatefailed.GetRemark();
                    return result;
                }
                if (!FileUtil.ExistsDir(generatorpath))
                {
                    FileUtil.CreateDirectory(generatorpath);
                }
                if (!FileUtil.Exists(generatorpath +"\\" + filename))
                {
                    var showlist = generators.Where(o => o.istitle && !o.isadditional);
                    var hbllist = ""; //当前显示列超过16列设置
                    if (showlist.Count() >= 14 || generators.Any(o=>o.isadditional))
                    {
                        hbllist = "[ '90px' ";
                        foreach (var item in showlist)
                        {
                            hbllist += ", '" + item.width + "px' ";
                        }
                        hbllist += ", '120px'];";
                        hbllist = "this.hblwidthConfig = " + hbllist;
                    }

                    #region 设置列表查询字段信息
                    var querylist = generators.Where(o => (o.isquery == true || o.isadd == true) && o.file.ToUpper() != "Id".ToUpper()).OrderBy(o => o.queryindex); //显示字段
                    StringBuilder ittmp = new StringBuilder();//下拉选择值初始化
                    foreach (var item in querylist)
                    {
                        if (item.querytype == 1 || item.querytype == 2 || item.querytype == 3 || item.querytype == 4)
                        {
                            ittmp.Append("this.validateForm.patchValue({ " + item.file + ": '-1' });\n\t\t\t");
                        }

                    }
                    #endregion

                    #region 设置列表查询字段数据集信息
                    var havedt = false;
                    var havedtsql = string.Empty;
                    StringBuilder qtlist = new StringBuilder();
                    var qitmp = ""; // 查询模型初始化
                    var qstmp = string.Empty;//下拉改变值方法
                    StringBuilder aitmp = new StringBuilder(); // 自动补全下拉改变值方法
                    StringBuilder qdtmp = new StringBuilder();//下拉数据集获取数据方法
                    StringBuilder instmp = new StringBuilder();//下拉数据集方法初始化
                    //string htmpa = string.Empty; //http服务
                    //string htmpb = string.Empty; // http服务引入
                    string htmpc = string.Empty; // rxjs引入
                    StringBuilder viewtmpb = new StringBuilder();//自动填充动态组件
                    var viewtmpa = string.Empty; // 引入ViewChild
                    StringBuilder initaftmp = new StringBuilder();//设置initAfter信息
                    StringBuilder initaftmpb = new StringBuilder();//设置initAfter信息
                    StringBuilder jlxltmp = new StringBuilder(); //设置上级下拉级联信息
                    StringBuilder jltmp = new StringBuilder(); // 设置上下级联对象
                    StringBuilder mrtmp = new StringBuilder(); // 设置上级下拉级联集合初始化信息
                    StringBuilder additmp = new StringBuilder(); // 设置多选下拉初始化
                    StringBuilder savetmp = new StringBuilder(); // 设置多选下拉提交时设置
                    var qindex = 0;
                    foreach (var item in querylist)
                    {
                        // 设置initAfter信息
                        if (qindex == 0 && querylist.Any(o => o.querytype == 6 && !string.IsNullOrEmpty(o.autovalue)) && querylist.Any(o => o.isquerymore) == false)
                        {
                            initaftmp.Append("initAfter() {\n\t\t\t");
                        }
                        if (qindex == querylist.Count() - 1 && querylist.Any(o => o.querytype == 6 && !string.IsNullOrEmpty(o.autovalue)) && querylist.Any(o => o.isquerymore) == false)
                        {
                            initaftmp.Append("}\n");
                        }
                        if (item.querytype == 1 || item.querytype == 3 || item.querytype == 8 || item.querytype == 9)
                        {
                            if (string.IsNullOrEmpty(qitmp))
                            {
                                if (type == 1)
                                {
                                    qitmp = "public Info: " + entityname + ";";
                                }
                                if (type == 2)
                                {
                                    qitmp = "public override Info!: " + entityname + ";";
                                }
                            }
                        }
                        if (item.querytype == 2 || item.querytype == 4 || item.querytype == 6)
                        {
                            if (string.IsNullOrEmpty(qitmp))
                            {
                                if (type == 1)
                                {
                                    qitmp = "public Info: " + entityname + ";";
                                }
                                if (type == 2)
                                {
                                    qitmp = "public override Info!: " + entityname + ";";
                                }
                            }
                            havedt = true;
                            if (!string.IsNullOrEmpty(item.querystra))
                            {
                                havedtsql = item.querystra.Split('|')[0];
                            }
                            if (!string.IsNullOrEmpty(item.querystrc))
                            {
                                havedtsql = item.querystrc.Split('|')[0];
                            }
                        }
                        if (item.querytype != 7)
                        {
                            StringBuilder datastr = new StringBuilder();
                            var querytypes = new[] { 2, 4, 6 }; //动态SQL获取数据集
                            var querytypesb = new[] { 1, 3, 5 }; //静态数组获取数据集
                            var changesetvalue = string.Empty;
                            if (querytypes.Any(o => o == item.querytype)) // 动态数据集获取方法
                            {
                                var svs = new string[] { };
                                if (!string.IsNullOrEmpty(item.querystra))
                                {
                                    svs = item.querystra.Split('|')[1].Split(',');
                                }
                                if (!string.IsNullOrEmpty(item.querystrb))
                                {
                                    svs = item.querystra.Split('|')[1].Split(',');
                                }
                                if (!string.IsNullOrEmpty(item.querystrc))
                                {
                                    svs = item.querystrc.Split('|')[1].Split(',');
                                }
                                if (item.querytype != 6) // 下拉数据集获取方法
                                {
                                    datastr.Append("\t\t\tresult.data.map((res:any, ind:any)=>{\n\t\t\tnewlist.push({label:res." + svs[0] + ",value:res." + svs[1] + "});});");
                                }
                                else //自动补全数据集获取方法
                                {
                                    if (!string.IsNullOrEmpty(item.autovalue))
                                    {
                                        datastr.Append("\t\t\tresult.data.map((res:any, ind:any)=>{\n\t\t\t	if (ind <= 500) {\n\t\t\tnewlist.push(res." + svs[0] + ");\n\t\t\t}\n\t\t\t});\n\t\t\t");
                                        datastr.Append("if(result.data.length>500){\n\t\t\tthis.auto" + item.file.FirstCharToUpper() + " = true;\n\t\t\t}\n\t\t\tif(result.data.length===1){\n\t\t\t\n}\n\t\t\t");
                                    }
                                    else
                                    {
                                        datastr.Append("\t\t\tresult.data.map((res:any, ind:any)=>{\n\t\t\tnewlist.push(res." + svs[0] + ");\n\t\t\t});");
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(item.changesetvalue))
                            {
                                changesetvalue = "this.validateForm.patchValue({ " + item.changesetvalue + ": data });\n\t";
                            }
                            if (qindex == 0)
                            {
                                string autoxl = string.Empty;
                                if (item.querytype == 5 || item.querytype == 6)
                                {
                                    if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                    {
                                        var autovalue = string.Empty;
                                        if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                        {
                                            autovalue = "" + item.autovalue + ":data";
                                        }
                                        initaftmp.Append("this.validateForm.get('" + item.file + "').valueChanges.pipe(debounceTime(400), distinctUntilChanged()).subscribe((data:any) => {");
                                        initaftmpb.Append("this.validateForm.get('" + item.file + "').valueChanges.pipe(debounceTime(400), distinctUntilChanged()).subscribe((data:any) => {");
                                        viewtmpb.Append("@ViewChild('auto" + item.file.FirstCharToUpper() + "') auto" + item.file.FirstCharToUpper() + ": any;");
                                        viewtmpa = "ViewChild,";
                                        autoxl = "\n\t\t\t this.http.HttpGetList('api/" + entityname + "/Get" + item.file.FirstCharToUpper() + "List', {" + autovalue + "},\n\t\t\t";
                                        autoxl += "(result:any) => {\n\t\t\tif (result.success) {\n\t\t\tconst newlist:any[] =[];\n " + datastr.ToString() + "\n\t\t\tthis." + item.file.FirstCharToUpper() + "List\t=\tnewlist;}\n\t\t\t}, (error:any) => {\n\t\t\t\n\t\t\t});\n\t\t\t}\n\t\t\t);\n\t\t\t";
                                        initaftmp.Append(autoxl);
                                        initaftmpb.Append(autoxl);
                                        StringBuilder inputfil = new StringBuilder();
                                        inputfil.Append("if (value !== '') {\n\tconst list:any[] = [];\n\tthis." + item.file.FirstCharToUpper() + "List.map((res:any) => {\n\t if (res.indexOf(value) !== -1) {\n\t");
                                        inputfil.Append("list.push(res);\n\t}\n\t});\n\tif (list.length > 0) {\n\tthis." + item.file.FirstCharToUpper() + "List = list;\n\t}\n\tthis.cer.markForCheck();\n\tthis.cer.detectChanges();\n\t}\n\t");
                                        aitmp.Append("onInput" + item.file.FirstCharToUpper() + "(value: string) {\n\t\t" + inputfil.ToString() + "}");
                                    }
                                    else
                                    {
                                        aitmp.Append("onInput" + item.file.FirstCharToUpper() + "(value: string) {\n\t\t" + changesetvalue + "}");
                                    }
                                }
                                if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                {
                                    qstmp = item.file.FirstCharToUpper() + "Change(data:any) {\n\t\t}";
                                }
                                else if (item.querytype == 12)
                                {
                                    if (!string.IsNullOrEmpty(item.changesetvalueb))
                                    {
                                        jltmp.Append("" + item.changesetvalueb.FirstCharToUpper() + "List: any[] = [];\n\t\t");
                                        mrtmp.Append("this." + item.changesetvalueb.FirstCharToUpper() + "List = this.Info." + item.changesetvalueb.FirstCharToUpper() + "List; \n\t\t");
                                        jlxltmp.Append(item.file.FirstCharToUpper() + "Change(data:any) { \n\t\tthis." + item.changesetvalueb.FirstCharToUpper() + "List = this.Info." + item.changesetvalueb.FirstCharToUpper() + "List.filter((o:any)=>o.pid===data).map((res:any)=> res);\n\t\t if (this." + item.changesetvalueb.FirstCharToUpper() + "List.length > 0) {\n\t\t this.validateForm.patchValue({ " + item.changesetvalueb + ": this." + item.changesetvalueb.FirstCharToUpper() + "List[0].value });\n\t\t} else {\n\t\tthis.validateForm.patchValue({ " + item.changesetvalueb + ": '无' });\n\t\t }\n\t\tthis.cer.markForCheck();\n\t\t}");
                                    }
                                }
                                else if(item.querytype==3 || item.querytype == 4)
                                {
                                    additmp.Append("this.validateForm.patchValue({" + item.file + ": this.selectEditData." + item.file + ".split(',')});\n\t\t");
                                    savetmp.Append("data." + item.file + " = data." + item.file + ".join(',');\n\t\t");
                                    qstmp = item.file.FirstCharToUpper() + "Change(data:any) {\n\t\t }";
                                }
                                else
                                {
                                    qstmp = item.file.FirstCharToUpper() + "Change(data) {\n\t\t" + changesetvalue + "}";
                                }
                                if (querytypes.Any(o => o == item.querytype)) // 动态数据集获取方法
                                {
                                    qtlist.Append("" + item.file.FirstCharToUpper() + "List:any[] = [];");
                                    //htmpa = "import { HttpClientService } from '../../../services/httpclient.service';";
                                    if (item.querytype == 6 || !string.IsNullOrEmpty(item.autovalue))
                                    {
                                        htmpc = "\nimport { debounceTime, distinctUntilChanged } from 'rxjs/operators';";
                                    }
                                    //htmpb = ", private http: HttpClientService";
                                    if (item.querytype != 6)
                                    {
                                        qdtmp.Append("init" + item.file.FirstCharToUpper() + "List() {\n\t\t\t this.http.HttpGetList('api/" + entityname + "/Get" + item.file.FirstCharToUpper() + "List', {},\n\t\t\t");
                                        qdtmp.Append("(result:any) => {\n\t\t\tconst newlist:any[] =[];\n " + datastr.ToString() + "\n\t\t\tthis." + item.file.FirstCharToUpper() + "List\t=\tnewlist;}, (error:any) => {\n\t\t\t\n\t\t\t});\n\t\t\t}\n");
                                        instmp.Append("\tthis.init" + item.file.FirstCharToUpper() + "List();\n\t");
                                    }
                                }
                            }
                            else
                            {
                                string autoxl = string.Empty;
                                if (item.querytype == 5 || item.querytype == 6)
                                {
                                    if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                    {
                                        var autovalue = string.Empty;
                                        if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                        {
                                            autovalue = "" + item.autovalue + ":data";
                                        }
                                        initaftmp.Append("this.validateForm.get('" + item.file + "').valueChanges.pipe(debounceTime(400), distinctUntilChanged()).subscribe((data:any) => {");
                                        initaftmpb.Append("this.validateForm.get('" + item.file + "').valueChanges.pipe(debounceTime(400), distinctUntilChanged()).subscribe((data:any) => {");
                                        viewtmpb.Append("@ViewChild('auto" + item.file.FirstCharToUpper() + "') auto" + item.file.FirstCharToUpper() + ": any;");
                                        viewtmpa = "ViewChild,";
                                        autoxl = "\n\t\t\t this.http.HttpGetList('api/" + entityname + "/Get" + item.file.FirstCharToUpper() + "List', {" + autovalue + "},\n\t\t\t";
                                        autoxl += "(result:any) => {\n\t\t\tif (result.success) {\n\t\t\tconst newlist:any[] =[];\n " + datastr.ToString() + "\n\t\t\tthis." + item.file.FirstCharToUpper() + "List\t=\tnewlist;}\n\t\t\t}, (error:any) => {\n\t\t\t\n\t\t\t});\n\t\t\t}\n\t\t\t);\n\t\t\t";
                                        initaftmp.Append(autoxl);
                                        initaftmpb.Append(autoxl);
                                        StringBuilder inputfil = new StringBuilder();
                                        inputfil.Append("if (value !== '') {\n\tconst list:any[] = [];\n\tthis." + item.file.FirstCharToUpper() + "List.map((res:any) => {\n\t if (res.indexOf(value) !== -1) {\n\t");
                                        inputfil.Append("list.push(res);\n\t}\n\t});\n\tif (list.length > 0) {\n\tthis." + item.file.FirstCharToUpper() + "List = list;\n\t}\n\tthis.cer.markForCheck();\n\tthis.cer.detectChanges();\n\t}\n\t");
                                        aitmp.Append("\n\n\tonInput" + item.file.FirstCharToUpper() + "(value: string) {\n\t\t\n\t" + inputfil.ToString() + "}");
                                    }
                                    else
                                    {
                                        aitmp.Append("\n\n\tonInput" + item.file.FirstCharToUpper() + "(value: string) {\n\t\t\n\t" + changesetvalue + "}");
                                    }
                                }
                                if (item.querytype == 6 && !string.IsNullOrEmpty(item.autovalue))
                                {
                                    qstmp += "\n\n\t" + item.file.FirstCharToUpper() + "Change(data:any) {\n\t\t}";
                                }
                                else if (item.querytype == 12)
                                {
                                    if (!string.IsNullOrEmpty(item.changesetvalueb))
                                    {
                                        jltmp.Append("" + item.changesetvalueb.FirstCharToUpper() + "List:any[] = [];\n\t\t");
                                        mrtmp.Append("this." + item.changesetvalueb.FirstCharToUpper() + "List = this.Info." + item.changesetvalueb.FirstCharToUpper() + "List; \n\t\t");
                                        jlxltmp.Append(item.file.FirstCharToUpper() + "Change(data:any) { \n\t\tthis." + item.changesetvalueb.FirstCharToUpper() + "List = this.Info." + item.changesetvalueb.FirstCharToUpper() + "List.filter((o:any)=>o.pid===data).map((res:any)=> res);\n\t\t if (this." + item.changesetvalueb.FirstCharToUpper() + "List.length > 0) {\n\t\t this.validateForm.patchValue({ " + item.changesetvalueb + ": this." + item.changesetvalueb.FirstCharToUpper() + "List[0].value });\n\t\t} else {\n\t\tthis.validateForm.patchValue({ " + item.changesetvalueb + ": '无' });\n\t\t }\n\t\tthis.cer.markForCheck();\n\t\t}\n\t\t");
                                    }
                                }
                                else if (item.querytype == 3 || item.querytype == 4)
                                {
                                    additmp.Append("this.validateForm.patchValue({" + item.file + ": this.selectEditData." + item.file + ".split(',')});\n\t\t");
                                    savetmp.Append("data." + item.file + " = data." + item.file + ".join(',');\n\t\t");
                                    qstmp = "\n\n\t" + item.file.FirstCharToUpper() + "Change(data:any) {\n\t\t }";
                                }
                                else
                                {
                                    qstmp += "\n\n\t" + item.file.FirstCharToUpper() + "Change(data:any) {\n\t\t" + changesetvalue + "}";
                                }
                                if (querytypes.Any(o => o == item.querytype)) // 动态数据集获取方法
                                {
                                    qtlist.Append("\n\t\t" + item.file.FirstCharToUpper() + "List:any[] = [];");
                                    //htmpa = "import { HttpClientService } from '../../../services/httpclient.service';";
                                    if (item.querytype == 6 || !string.IsNullOrEmpty(item.autovalue))
                                    {
                                        htmpc = "\nimport { debounceTime, distinctUntilChanged } from 'rxjs/operators';";
                                    }
                                    //htmpb = ", private http: HttpClientService";
                                    if (item.querytype != 6)
                                    {
                                        qdtmp.Append("\n\n\tinit" + item.file.FirstCharToUpper() + "List() {\n\t\t\t this.http.HttpGetList('api/" + entityname + "/Get" + item.file.FirstCharToUpper() + "List', { },\n\t\t\t");
                                        qdtmp.Append("(result:any) => {\n\t\t\tconst newlist:any[] = [];\n " + datastr.ToString() + "\n\t\t\tthis." + item.file.FirstCharToUpper() + "List\t=\tnewlist;}, (error:any) => {\n\t\t\t\n\t\t\t});\n\t\t\t}\n");
                                        instmp.Append("\tthis.init" + item.file.FirstCharToUpper() + "List();\n\t");
                                    }
                                }
                            }
                        }
                        qindex++;
                    }
                    if (havedt && string.IsNullOrEmpty(havedtsql))
                    {
                        result.msg = ImplementResult.ParameterException.GetRemark();
                        return result;
                    }
                    #endregion

                    #region 设置查询表单初始化信息
                    StringBuilder quermorelist = new StringBuilder();//多条件设置
                    if (generators.Any(o => o.isquerymore))
                    {
                        if (type == 1)
                        {
                            qitmp = "public Info: " + entityname + ";";
                        }
                        if (type == 2)
                        {
                            qitmp = "public override Info!: " + entityname + ";";
                        }
                        var newquery = generators.Where(o => o.isquery && o.isadditional == false).OrderBy(o => o.titleindex);
                        quermorelist.Append("initAfter() {\n");
                        quermorelist.Append("\t\tthis.Info.iscustom = true;\n");
                        if (generators[0].pagesize > 10)
                        {
                            quermorelist.Append("\t\tthis.pageSize = 20;\n");
                            quermorelist.Append("\t\tthis.pageSizeb = 20;\n");
                        }
                        var id = 0;
                        StringBuilder quermorelista = new StringBuilder();
                        StringBuilder quermorelistb = new StringBuilder();
                        foreach (var item in newquery)
                        {
                            if (id == 0)
                            {
                                quermorelista.Append("\t\tthis.validateForm = this.fb.group({\n");
                                quermorelistb.Append("this.validateFormb = this.fb.group({\n");
                            }
                            if (item.querytype == 1 || item.querytype == 3)
                            {
                                quermorelista.Append("\t\t\t" + item.file + ": [" + item.defaultvalue + "],\n");
                                quermorelistb.Append("\t\t\t" + item.file + ": [" + item.defaultvalue + "],\n");
                            }
                            else
                            {
                                quermorelista.Append("\t\t\t" + item.file + ": ['" + item.defaultvalue + "'],\n");
                                quermorelistb.Append("\t\t\t" + item.file + ": ['" + item.defaultvalue + "'],\n");
                            }
                            if (id == newquery.Count() - 1)
                            {
                                quermorelista.Append("status: ['-1']\n\t\t});\n");
                                quermorelistb.Append("status: ['-9']\n\t\t});\n");
                            }
                            id++;
                        }
                        quermorelist.Append(quermorelista.ToString() + "\n\t\t\t" + quermorelistb.ToString() + "");
                        if (querylist.Any(o => o.querytype == 6 && !string.IsNullOrEmpty(o.autovalue)))
                        {
                            quermorelist.Append(initaftmp.ToString());
                            initaftmp = initaftmp.Clear();
                        }
                        quermorelist.Append("\t}\n");
                    }
                    #endregion

                    #region 设置文件上传信息
                    StringBuilder uftmp = new StringBuilder();
                    var fulist = generators.Where(o => o.querytype == 10).OrderBy(o => o.editindex);
                    foreach (var item in fulist)
                    {
                        uftmp.Append(" Upload" + item.file.FirstCharToUpper() + "(data:any) {\n\t\t\t console.info(678, data)\n\t\t\t}\n\t\t\t");
                    }
                    #endregion

                    #region 设置文件预览信息
                    StringBuilder previewtmp = new StringBuilder();
                    var havepreview = generators.Where(o => o.querytype == 11);
                    string ylfptmp = string.Empty;
                    string yltmpfun = string.Empty;
                    string ylheighttmp = string.Empty;
                    if (havepreview.Count() > 0)
                    {
                        ylheighttmp = "heightValue = '700';";
                        //htmpa = "import { HttpClientService } from '../../../services/httpclient.service';\n\t\timport { DomSanitizer } from '@angular/platform-browser';\n\t\t";
                        //htmpb = ", private sanitizer: DomSanitizer";
                        ylfptmp = "fielname = '';\n\t\tfilePath: any;\n\t\tvisible = false;\n\t\tcurroutename = '';\n\t\tdownloadfileapi = '';\n\t\t";
                        yltmpfun = "downloadfile() {\n\t\twindow.open( this.downloadfileapi);\n\t\t}\n\t\t";
                        foreach (var item in havepreview)
                        {
                            previewtmp.Append("show" + item.file.FirstCharToUpper() + "file(data:any, fielname:any) {\n\t\t\tthis.fielname = fielname;\n\t\tthis.curroutename = this.Info.getInfo(data);\n\t\t");
                            previewtmp.Append("this.visible = true;\n\t\tif (!this.Info.judge(fielname)) {\n\t\tthis.initylpath(fielname);\n\t\t} else {\n\t\t");
                            previewtmp.Append("this.downloadfileapi = this.http.ymPath + this.Info.DownFileApi + fielname;\n\t\tconst url = this.http.ymPath  + fielname;\n\t\t");
                            previewtmp.Append("this.filePath = this.sanitizer.bypassSecurityTrustResourceUrl(url);\n\t\t}\n\t\t}\n\t\t");
                        }
                        previewtmp.Append("\n\t\tinitylpath(path) {\n\t\tlet url = '';\n\t\tthis.http.httpPost('api/Spconf/GetList', {\n\t\tpageSize: 10, pageIndex: 1, sortType: 'desc',\n\t\t");
                        previewtmp.Append("sortFile: 'Id', sCode: 'previewpath'\n\t\t }, result => {\n\t\tif (result.success && result.count > 0) {\n\t\t");
                        previewtmp.Append("url = result.data[0].sValue + this.http.ymPath + path;\n\t\t} else {\n\t\turl = this.http.previewpath + this.http.ymPath + path;\n\t\t}\n\t\t");
                        previewtmp.Append("this.downloadfileapi = this.http.ymPath + this.Info.DownFileApi + path;\n\t\tthis.filePath = this.sanitizer.bypassSecurityTrustResourceUrl(url);\n\t\t");
                        previewtmp.Append("}, (error:any) => {\n\t\turl = this.http.previewpath + this.http.ymPath + path;\n\t\t});\n\t\t}\n\t\t");
                        previewtmp.Append("\n\t\tclose() {\n\t\tthis.visible = false;\n\t\t}\n\t\t");
                    }
                    #endregion

                    #region 设置下拉根据对应值显示对应内容信息
                    StringBuilder fileshowb = new StringBuilder();
                    var fileshowbdata = generators.Where(o => o.fileshowb);
                    foreach (var item in fileshowbdata)
                    {
                        fileshowb.Append("show"+item.file.FirstCharToUpper()+"(data:any){\n\t\t\tlet value='';\n\tthis.Info."+item.file.FirstCharToUpper()+ "List.map((res:any)=>{if(res.value===data){value=res.label;}});\n\t\t return value;}\n\n\t");
                    }
                    #endregion

                    var writecount = generators.Count(o => o.isedit == true && o.file.ToUpper() != "Remark".ToUpper() && o.file.ToUpper() != "status".ToUpper() && o.file.ToUpper() != "Id".ToUpper() && o.file.ToUpper() != "ctime".ToUpper() && o.file.ToUpper() != "utime".ToUpper());
                    var edtmp = "'25%';";
                    if (writecount >= 10)
                    {
                        edtmp = "'50%';";
                    }
                    StringBuilder bastmpa = new StringBuilder();
                    var bastmpb = string.Empty;
                    if (type == 1)
                    {
                        bastmpb = "BaseComponent";
                        bastmpa.Append("import { BaseComponent } from '../../common/IndexBase';\n\n");
                    }
                    if (type == 2)
                    {
                        bastmpb = "BaseComponentDirective";
                        bastmpa.Append("import { BaseComponentDirective } from 'src/app/pages/modules/common/IndexBase';\n");
                        bastmpa.Append("import { DomSanitizer } from '@angular/platform-browser';\n\n");
                    }
                    var isover = string.Empty;
                    var issa = string.Empty;
                    var issb = string.Empty;
                    if (type == 2)
                    {
                        isover = "override";
                        issa = ", public override sanitizer: DomSanitizer";
                        issb = ", sanitizer";
                    }
                    string newjson = json.Replace("templaterb", model)
                    .Replace("intqu", quermorelist.ToString())
                    .Replace("aitmp", aitmp.ToString())
                    .Replace("qitmp", qitmp)
                    .Replace("qtlist", qtlist.ToString())
                    .Replace("qstmp", qstmp)
                    .Replace("qdtmp", qdtmp.ToString())
                    .Replace("instmp", instmp.ToString())
                    //.Replace("htmpa", htmpa)
                    //.Replace("htmpb", htmpb)
                    .Replace("htmpc", htmpc)
                    .Replace("ylfptmp", ylfptmp)
                    .Replace("yltmpfun", yltmpfun)
                    .Replace("ylheighttmp", ylheighttmp)
                    .Replace("previewtmp", previewtmp.ToString())
                    .Replace("viewtmpa", viewtmpa)
                    .Replace("viewtmpb", viewtmpb.ToString())
                    .Replace("initaftmp", initaftmp.ToString())
                    .Replace("edtmp", edtmp)
                    .Replace("fileshowb", fileshowb.ToString())
                    .Replace("hbllist", hbllist)
                    .Replace("module", directoryname)
                    .Replace("bastmpa", bastmpa.ToString())
                    .Replace("bastmpb", bastmpb.ToString())
                    .Replace("isover", isover)
                    .Replace("issa", issa)
                    .Replace("issb", issb)
                    .Replace("tbname", entityname);
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        FileUtil.CreateDirectory(generatorpath);
                    }
                    if (!FileUtil.Exists(generatorpath+"\\" + filename))
                    {
                        FileUtil.WriteFile(generatorpath, filename, newjson);
                        if (isedit)
                        {
                            filename = $"add\\index.ts";
                            if (!FileUtil.ExistsDir(generatorpath + "\\add"))
                            {
                                FileUtil.CreateDirectory(generatorpath + "\\add");
                            }
                            if (!FileUtil.Exists(generatorpath + "\\" + filename))
                            {
                                json = FileUtil.ReadFile(fileNameIndexAdd);
                                json = AesEncryptionUtil.AESDecrypt(json, out var msgaa);
                                if (!msgaa.IsNull())
                                {
                                    result.msg = ImplementResult.Templatefailed.GetRemark();
                                    return result;
                                }
                                var instmpstr = string.Empty;
                                if (!string.IsNullOrEmpty(instmp.ToString()) || !string.IsNullOrEmpty(initaftmpb.ToString()))
                                {
                                    instmpstr = "initAfter() {\n\t\t\t" + instmp.ToString() + initaftmpb + "}\n";
                                }
                                #region 设置预览信息
                                var nzAccepttmp = string.Empty;
                                var ylsertmp = string.Empty;
                                var ylimportmp = string.Empty;
                                StringBuilder filepathtmp = new StringBuilder();
                                StringBuilder uploadApitmp = new StringBuilder();
                                StringBuilder filelisttmp = new StringBuilder();
                                StringBuilder ylfuntmp = new StringBuilder();
                                StringBuilder uploadserapitmp = new StringBuilder();
                                if (!string.IsNullOrEmpty(ylfptmp))
                                {
                                    ylimportmp = "declare var $: any;\n\t\timport { UploadXHRArgs } from 'ng-zorro-antd/upload';\n\t\timport { HttpClient, HttpEvent, HttpEventType, HttpRequest, HttpResponse } from '@angular/common/http';\n\t\t";
                                    ylsertmp = ", private httpys: HttpClient";
                                    nzAccepttmp = "nzAccept = 'image/png,image/jpeg,image/jpg,image/gif,.pdf,.txt,.json,.html,.xls,.xlsx,.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document';";
                                    ylfuntmp.Append("downloadfile(data:any) {\n\t\tdata.map((res:any) => {\n\t\tsetTimeout(() => {\n\t\t$.ajax({\n\t\t");
                                    ylfuntmp.Append("url: res,\n\t\tsuccess:  (datab:any) => {\n\t\twindow.location.href = res;\n\t\t}\n\t\t});\n\t\t}, 800);\n\t\t });\n\t\t}\n\t\t");
                                    foreach (var item in havepreview)
                                    {
                                        filepathtmp.Append("filepath" + item.file.FirstCharToUpper() + " ='';\n\t\t");
                                        uploadApitmp.Append("uploadApi" + item.file.FirstCharToUpper() + " = '';\n\t\t");
                                        filelisttmp.Append("" + item.file.FirstCharToUpper() + "filelist:any[] = [];\n\t\t");

                                        uploadserapitmp.Append("this.uploadApi" + item.file.FirstCharToUpper() + " = this.http.url + this.Info.uploadApi" + item.file.FirstCharToUpper() + ";\n\t\t");

                                        ylfuntmp.Append("\nupload" + item.file.FirstCharToUpper() + " = (item: any) => {\n\t\t");
                                        ylfuntmp.Append("// Create a FormData here to store files and other parameters.\n\t\t");
                                        ylfuntmp.Append("const formData = new FormData();\n\t\t");
                                        ylfuntmp.Append("// tslint:disable-next-line:no-any\n\t\t");
                                        ylfuntmp.Append("formData.append('file', item.file as any);\n\t\t");
                                        ylfuntmp.Append(" // tslint:disable-next-line: no-non-null-assertion\n\t\t");
                                        ylfuntmp.Append("const req = new HttpRequest('POST', item.action!, formData, {\n\t\t reportProgress: true,\n\t\twithCredentials: false\n\t\t});\n\t\t");
                                        ylfuntmp.Append("// Always returns a `Subscription` object. nz-upload would automatically unsubscribe it at correct time.\n\t\t");
                                        ylfuntmp.Append("return this.httpys.request(req).subscribe(\n\t\t");
                                        ylfuntmp.Append("(event: HttpEvent<{}>) => {\n\t\t");
                                        ylfuntmp.Append("if (event.type === HttpEventType.UploadProgress) {\n\t\t");
                                        ylfuntmp.Append("// tslint:disable-next-line: no-non-null-assertion\n\t\t");
                                        ylfuntmp.Append(" if (event.total! > 0) {\n\t\t// tslint:disable-next-line:no-any\n\t\t// tslint:disable-next-line: no-non-null-assertion\n\t\t");
                                        ylfuntmp.Append(" (event as any).percent = (event.loaded / event.total!) * 100;\n\t\t}\n\t\t");
                                        ylfuntmp.Append("// tslint:disable-next-line: no-non-null-assertion\n\t\t item.onProgress!(event, item.file!);\n\t\t");
                                        ylfuntmp.Append("} else if (event instanceof HttpResponse) {\n\t\t const result = (event as any).body;\n\t\t");
                                        ylfuntmp.Append("if (result.success) {\n\t\tthis.filepath" + item.file.FirstCharToUpper() + " += result.data + ',';\n\t\t}\n\t\t");
                                        ylfuntmp.Append("if (this.selectEditData !== null && this.selectEditData !== undefined) {\n\t\t");
                                        ylfuntmp.Append("this.validateForm.patchValue({ " + item.file + ": this.selectEditData." + item.file + " + ',' + this.filepath" + item.file.FirstCharToUpper() + " });\n\t\t");
                                        ylfuntmp.Append("} else {\n\t\tthis.validateForm.patchValue({ " + item.file + ": this.filepath" + item.file.FirstCharToUpper() + " });\n\t\t}\n\t\t");
                                        ylfuntmp.Append("// tslint:disable-next-line: no-non-null-assertion\n\t\titem.onSuccess!(event.body, item.file!, event);\n\t\t");
                                        ylfuntmp.Append("}\n\t\t},\n\t\terr => {\n\t\t// tslint:disable-next-line: no-non-null-assertion\n\t\titem.onError!(err, item.file!);\n\t\t");
                                        ylfuntmp.Append("}\n\t\t);\n\t\t}\n\t\t");
                                    }
                                }
                                #endregion
                                var additmpstr = string.Empty;
                                if (!string.IsNullOrEmpty(additmp.ToString()))
                                {
                                    additmpstr = "initAfter() {\n\t\tif(this.selectEditData) {\n\t\t try {\n\t\t "+additmp.ToString()+" \n\t\t} catch (e:any) {\n\n\t\t}\n\t\t}\n\t\t}\n\t\t";
                                }
                                var savetmpstr = string.Empty;
                                if (!string.IsNullOrEmpty(savetmp.ToString()))
                                {
                                    savetmpstr = "submitFormBefore(data:any, va:any){ \n\t\ttry {\n\t\t "+savetmp.ToString()+"\n\t\t} catch (e:any) {\n\t\t}\n\t\t }\n\t\t";
                                }
                                bastmpa.Clear();
                                bastmpb = string.Empty;
                                if (type == 1)
                                {
                                    bastmpa.Append("import { BaseAddComponent } from '../../../common/IndexAddBase';");
                                    bastmpb = "BaseAddComponent";
                                }
                                if (type == 2)
                                {
                                    bastmpa.Append("import { BaseAddDirective } from 'src/app/pages/modules/common/IndexAddBase';");
                                    bastmpb = "BaseAddDirective";
                                }

                                json = json.Replace("temname", model).Replace("table", entityname)
                                .Replace("isover", isover)
                                .Replace("module", directoryname)
                                .Replace("uftmp", uftmp.ToString())
                                //.Replace("htmpb", htmpb)
                                .Replace("htmpc", htmpc)
                                .Replace("nzAccepttmp", nzAccepttmp)
                                .Replace("ylsertmp", ylsertmp)
                                .Replace("ylimportmp", ylimportmp)
                                .Replace("uploadserapitmp", uploadserapitmp.ToString())
                                .Replace("filepathtmp", filepathtmp.ToString())
                                .Replace("uploadApitmp", uploadApitmp.ToString())
                                .Replace("filelisttmp", filelisttmp.ToString())
                                .Replace("ylfuntmp", ylfuntmp.ToString())
                                .Replace("jltmp", jltmp.ToString())
                                .Replace("mrtmp", mrtmp.ToString())
                                .Replace("jlxltmp", jlxltmp.ToString())
                                .Replace("viewtmpa", viewtmpa)
                                .Replace("viewtmpb", viewtmpb.ToString())
                                .Replace("aitmp", aitmp.ToString())
                                .Replace("qitmp", qitmp)
                                .Replace("qtlist", qtlist.ToString())
                                .Replace("qstmp", qstmp)
                                .Replace("qdtmp", qdtmp.ToString())
                                .Replace("edtmp", edtmp)
                                .Replace("ittmp", ittmp.ToString())
                                .Replace("jlxltmp", jlxltmp.ToString())
                                .Replace("additmp", additmpstr)
                                .Replace("savetmp", savetmpstr)
                                .Replace("bastmpa", bastmpa.ToString())
                                .Replace("bastmpb", bastmpb)
                                .Replace("instmp", instmpstr);
                                FileUtil.WriteFile(generatorpath, filename, json);
                            }
                        }
                    }
                }
                return result;
            });
        }

        /// <summary>
        /// 生成前端Html模块代码
        /// </summary>
        /// <param name="file">模板路径</param>
        /// <param name="exportPath">程序集路径</param>
        /// <param name="model">实体名称</param>
        /// <param name="module">模块名称</param>
        /// <param name="directoryname">所属模块目录名称</param>
        /// <param name="fileNameModule">Module模板路径</param>
        /// <param name="fileNameRoute">Route模板路径</param>
        /// <param name="isedit">是否生成编辑页面</param>
        /// <param name="fileNameHtmlAdd">编辑页面模板路径</param>
        /// <param name="fileNameShareModule">模块共享编辑模板路径</param>
        /// <param name="service">服务</param>
        /// <param name="generators">模板设置信息</param>
        /// <param name="type">1=(ng7版本) 2=(ng13版本)</param>
        /// <returns></returns>
        public async Task<CommonResult> ExecuteHtml(string file, string exportPath, string model, string module, string directoryname,
            string fileNameModule, string fileNameRoute, bool isedit, string fileNameHtmlAdd, string fileNameShareModule, IMySqlSugarService service, List<Generator> generators,int type)
        {
            return await Task.Factory.StartNew(() =>
            {
                model = model.Replace("`", "").Split('-')[1];
                model = model.ToLower();
                CommonResult result = new CommonResult();
                if (file.IsNull() || exportPath.IsNull() || model.IsNull() || module.IsNull() || directoryname.IsNull())
                {
                    result.msg = ImplementResult.ParameterException.GetRemark();
                    return result;
                }
                if (!FileUtil.Exists(file))
                {
                    result.msg = ImplementResult.FileNotExist.GetRemark();
                    return result;
                }

                string[] path = exportPath.Split(@"\");
                string newpath = string.Empty;
                var pindex = 0;
                foreach (var item in path)
                {
                    if (pindex < path.Length - 1)
                    {
                        newpath += item + "\\";
                    }
                    pindex++;
                }
                var generatorpath = string.Empty;
                if (type == 1)
                {
                    generatorpath = newpath + "webng\\src\\app\\modules\\" + directoryname + "\\" + model;
                }
                if (type == 2)
                {
                    generatorpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname + "\\" + model;

                }

                var filename = $"{model}.component.html";
                if (!FileUtil.Exists(generatorpath +"\\" + filename))
                {
                    var imtmp = ""; //导入属性设置
                    StringBuilder impzj = new StringBuilder(); //导入组件设置
                    if (generators[0].isimport)
                    {
                        imtmp = "[isShowImport]=\"true\" [isShowDownload]=\"true\" (importEvent)=\"importData()\" (downloadEvent)=\"download()\"";
                        impzj.Append("<app-import #Import [importTitle]=\"'导入" + module + "数据'\" [browseLabel]=\"'选择上传附件'\" [dropZoneTitle]=\"'选择上传附件'\"\n");
                        impzj.Append("[uploadLabel]=\"'导入" + module + "数据'\" [FileType]=\"FileType\" [oType]=\"2\" [importType]=\"5\" [importUrl]=\"Info.ImportApi\">\n</app-import>");
                    }

                    #region 设置查询字段信息
                    StringBuilder query = new StringBuilder();
                    var havedt = false;
                    var havedtsql = string.Empty;
                    var querylist = generators.Where(o => o.isquery).OrderBy(o => o.queryindex);
                    var titlelist = generators.Where(o => o.istitle == true).OrderBy(o => o.titleindex);
                    var qindex = 0;
                    var hbltmp = ""; //当显示列超过16列的时候设置
                    var nzScrotmp = ""; //当显示列超过16列的时候设置
                    StringBuilder querymore = new StringBuilder();//更多条件查询设置
                    var morequery = "";//是否更多条件查询
                    if (generators.Any(o => o.isquerymore))
                    {
                        morequery = "*ngIf=\"false\"";
                        querymore.Append("<app-searchoperation [nzWidth]=\"'50%'\" [nzTitle]=\"'" + module + "过滤条件'\" [parentInstance]=\"this\" (queryEvent)=\"query()\" [hidden]=\"viewtype == 3\">\n");
                        querymore.Append("\t\t <form nz-form [formGroup]=\"validateForm\" novalidate style=\"margin-bottom:160px;margin-top:20px;\">\n");
                    }
                    else
                    {
                        morequery = "*ngIf=\"1===1\"";
                    }
                    if (titlelist.Count() >= 14 || generators.Any(o=>o.isadditional))
                    {
                        hbltmp = "[hblwidthConfig]=\"hblwidthConfig\"";
                        if (titlelist.Count() > 16 && titlelist.Count() <= 24)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'1700px'\"";
                        }
                        if (titlelist.Count() > 24 && titlelist.Count() <= 30)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'2700px'\"";
                        }
                        if (titlelist.Count() > 30 && titlelist.Count() <= 36)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'3000px'\"";
                        }
                        if (titlelist.Count() > 36 && titlelist.Count() <= 40)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'3600px'\"";
                        }
                        if (titlelist.Count() > 40 && titlelist.Count() <= 45)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'4200px'\"";
                        }
                        if (titlelist.Count() > 45 && titlelist.Count() <= 50)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'4600px'\"";
                        }
                        if (titlelist.Count() > 50 && titlelist.Count() <= 57)
                        {
                            nzScrotmp = "[nzScrollWidth]=\"'4900px'\"";
                        }
                    }
                    if (!generators.Any(o => o.isquerymore))
                    {
                        foreach (var item in querylist)
                        {
                            var qis = string.Empty;
                            if (item.querytype == 1 || item.querytype == 3 || item.querytype == 5 || item.querytype == 8 || item.querytype == 9)
                            {
                                qis = "Info.";
                            }
                            if (item.querytype == 2 || item.querytype == 4 || item.querytype == 6)
                            {
                                havedt = true;
                                if (!string.IsNullOrEmpty(item.querystra))
                                {
                                    havedtsql = item.querystra.Split('|')[0];
                                }
                                if (!string.IsNullOrEmpty(item.querystrc))
                                {
                                    havedtsql = item.querystrc.Split('|')[0];
                                }
                            }
                            if (qindex == 0)
                            {
                                query.Append("<nz-form-item>\n\t\t\t<nz-form-label nzFor=\"" + item.file + "\">" + item.name.Split('-')[0] + "</nz-form-label>\n\t\t\t <nz-form-control>\n");
                                if (item.querytype == 7)
                                {
                                    query.Append("\t\t\t<input formControlName=\"" + item.file + "\" nz-input placeholder=\"" + item.name.Split('-')[0] + "\" />");
                                }
                                else
                                {
                                    switch (item.querytype)
                                    {
                                        case 1: //单选下拉静态值
                                        case 2: //单选下拉动态值
                                        case 3://多选下拉静态值
                                        case 4://多选下拉动态值
                                        case 8: //单选框
                                        case 9: //复选框
                                            var dx = string.Empty;
                                            if (item.querytype == 3 || item.querytype == 4)
                                            {
                                                dx = "[nzMode]=\"'multiple'\"";
                                            }
                                            var stitle = "label";
                                            if (item.querytype == 8)
                                            {
                                                stitle = "title";
                                            }
                                            query.Append("\t\t\t<nz-select " + dx + " formControlName=\"" + item.file + "\" nzPlaceHolder=\"" + item.name.Split('-')[0] + "\" style=\"width: 206px\" nzShowSearch nzAllowClear (ngModelChange)=\"" + item.file.FirstCharToUpper() + "Change($event)\">\n");
                                            query.Append("\t\t\t<nz-option nzValue=\"-1\" nzLabel=\"请选择\"></nz-option>\n");
                                            query.Append("\t\t\t<nz-option *ngFor=\"let option of " + qis + item.file.FirstCharToUpper() + "List\" [nzLabel]=\"option." + stitle + "\" [nzValue]=\"option.value\"></nz-option>\n");
                                            query.Append("\t\t\t</nz-select>");
                                            break;
                                        case 5://自动补全静态
                                        case 6://自动补全动态
                                            query.Append("\t\t\t<input [formControlName]=\"" + item.file + "\" placeholder=\"" + item.name.Split('-')[0] + "\" nz-input (input)= \"onInput" + item.file.FirstCharToUpper() + "($event.target?.value)\" [nzAutocomplete] = \"auto" + item.file.FirstCharToUpper() + "\" (ngModelChange)= \"" + item.file.FirstCharToUpper() + "Change($event)\" />\n");
                                            query.Append("\t\t\t<nz-autocomplete [nzDataSource]=\"" + qis + item.file.FirstCharToUpper() + "List\" #auto" + item.file.FirstCharToUpper() + "> </nz-autocomplete>");
                                            break;
                                    }
                                }
                                query.Append("\n\t\t\t</nz-form-control>\n\t\t\t</nz-form-item>");
                            }
                            else
                            {
                                if (qindex == querylist.Count() - 1)
                                {
                                    query.Append("\n<nz-form-item>\n\t\t\t<nz-form-label nzFor=\"" + item.file + "\">" + item.name.Split('-')[0] + "</nz-form-label>\n\t\t\t <nz-form-control>\n");
                                    if (item.querytype == 7)
                                    {
                                        query.Append("\t\t\t<input formControlName=\"" + item.file + "\" nz-input placeholder=\"" + item.name.Split('-')[0] + "\" />");
                                    }
                                    else
                                    {
                                        switch (item.querytype)
                                        {
                                            case 1: //单选下拉静态值
                                            case 2: //单选下拉动态值
                                            case 3://多选下拉静态值
                                            case 4://多选下拉动态值
                                            case 8: //单选框
                                            case 9: //复选框
                                                var dx = string.Empty;
                                                if (item.querytype == 3 || item.querytype == 4)
                                                {
                                                    dx = "[nzMode]=\"'multiple'\"";
                                                }
                                                var stitle = "label";
                                                if (item.querytype == 8)
                                                {
                                                    stitle = "title";
                                                }
                                                query.Append("\t\t\t<nz-select " + dx + " formControlName=\"" + item.file + "\" nzPlaceHolder=\"" + item.name.Split('-')[0] + "\" style=\"width: 206px\" nzShowSearch nzAllowClear (ngModelChange)=\"" + item.file.FirstCharToUpper() + "Change($event)\">\n");
                                                query.Append("\t\t\t<nz-option nzValue=\"-1\" nzLabel=\"请选择\"></nz-option>\n");
                                                query.Append("\t\t\t<nz-option *ngFor=\"let option of " + qis + item.file.FirstCharToUpper() + "List\" [nzLabel]=\"option." + stitle + "\" [nzValue]=\"option.value\"></nz-option>\n");
                                                query.Append("\t\t\t</nz-select>");
                                                break;
                                            case 5://自动补全静态
                                            case 6://自动补全动态
                                                query.Append("\t\t\t<input [formControlName]=\"" + item.file + "\" placeholder=\"" + item.name.Split('-')[0] + "\" nz-input (input)= \"onInput" + item.file.FirstCharToUpper() + "($event.target?.value)\" [nzAutocomplete] = \"auto" + item.file.FirstCharToUpper() + "\" (ngModelChange)= \"" + item.file.FirstCharToUpper() + "Change($event)\" />\n");
                                                query.Append("\t\t\t<nz-autocomplete [nzDataSource]=\"" + qis + item.file.FirstCharToUpper() + "List\" #auto" + item.file.FirstCharToUpper() + "> </nz-autocomplete>");
                                                break;
                                        }
                                    }
                                    query.Append("\n\t\t\t</nz-form-control>\n\t\t\t</nz-form-item>");
                                }
                                else
                                {
                                    query.Append("<nz-form-item>\n\t\t\t<nz-form-label nzFor=\"" + item.file + "\">" + item.name.Split('-')[0] + "</nz-form-label>\n\t\t\t <nz-form-control>\n");
                                    if (item.querytype == 7)
                                    {
                                        query.Append("\t\t\t<input formControlName=\"" + item.file + "\" nz-input placeholder=\"" + item.name.Split('-')[0] + "\" />");
                                    }
                                    else
                                    {
                                        switch (item.querytype)
                                        {
                                            case 1: //单选下拉静态值
                                            case 2: //单选下拉动态值
                                            case 3://多选下拉静态值
                                            case 4://多选下拉动态值
                                            case 8: //单选框
                                            case 9: //复选框
                                                var dx = string.Empty;
                                                if (item.querytype == 3 || item.querytype == 4)
                                                {
                                                    dx = "[nzMode]=\"'multiple'\"";
                                                }
                                                var stitle = "label";
                                                if (item.querytype == 8)
                                                {
                                                    stitle = "title";
                                                }
                                                query.Append("\t\t\t<nz-select " + dx + " formControlName=\"" + item.file + "\" nzPlaceHolder=\"" + item.name.Split('-')[0] + "\" style=\"width: 206px\" nzShowSearch nzAllowClear (ngModelChange)=\"" + item.file.FirstCharToUpper() + "Change($event)\">\n");
                                                query.Append("\t\t\t<nz-option nzValue=\"-1\" nzLabel=\"请选择\"></nz-option>\n");
                                                query.Append("\t\t\t<nz-option *ngFor=\"let option of " + qis + item.file.FirstCharToUpper() + "List\" [nzLabel]=\"option." + stitle + "\" [nzValue]=\"option.value\"></nz-option>\n");
                                                query.Append("\t\t\t</nz-select>");
                                                break;
                                            case 5://自动补全静态
                                            case 6://自动补全动态
                                                query.Append("\t\t\t<input [formControlName]=\"" + item.file + "\" placeholder=\"" + item.name.Split('-')[0] + "\" nz-input (input)= \"onInput" + item.file.FirstCharToUpper() + "($event.target?.value)\" [nzAutocomplete] = \"auto" + item.file.FirstCharToUpper() + "\" (ngModelChange)= \"" + item.file.FirstCharToUpper() + "Change($event)\" />\n");
                                                query.Append("\t\t\t<nz-autocomplete [nzDataSource]=\"" + qis + item.file.FirstCharToUpper() + "List\" #auto" + item.file.FirstCharToUpper() + "> </nz-autocomplete>");
                                                break;
                                        }
                                    }
                                    query.Append("\n\t\t\t</nz-form-control>\n\t\t\t</nz-form-item>\n");
                                }
                            }
                            qindex++;
                        }
                    }
                    if (havedt && string.IsNullOrEmpty(havedtsql))
                    {
                        result.msg = ImplementResult.ParameterException.GetRemark();
                        return result;
                    }
                    #endregion

                    #region 设置显示字段信息
                    StringBuilder titleshow = new StringBuilder(); // 列表字段显示定义
                    StringBuilder titleshowb = new StringBuilder();// 回收列表字段显示定义
                    var ishblist = generators.Any(o => o.isadditional == true);
                    var showlist = generators.Where(o => o.istitle == true).OrderBy(o => o.editindex);
                    var sindex = 0;
                    var zklengx = generators.Count() + 2; // 展开详情跨列
                    var showzk = ""; // 是否展开详情
                    if (generators.Any(o => o.isdetail == true))
                    {
                        showzk = "nzShowExpand";
                    }
                    foreach (var item in showlist)
                    {
                        if (item.isadditional)
                        {
                            continue;
                        }
                        var leftxp = "";
                        var tooltip = "";
                        if (ishblist)
                        {
                            if (item.isoffset && item.shiftleft > 0)
                            {
                                leftxp = "nzLeft=\"" + item.shiftleft + "px\"";
                            }
                        }
                        var iszkcon = "";
                        if (item.isdetail)
                        {
                            iszkcon = "| BackResult:'character':"+item.characterlen+"";
                            tooltip = " style=\"cursor: pointer;\" [nzTitle]=\"data." + item.file + "\" nzPlacement=\"bottomLeft\" nz-tooltip ";
                        }
                        StringBuilder previewhtml = new StringBuilder();
                        if (item.querytype == 11)
                        {
                            previewhtml.Append("<span *ngIf=\"data." + item.file + " !== '' && data." + item.file + " !== null && data." + item.file + " !== undefined\">\n\t\t");
                            previewhtml.Append("<span *ngFor=\"let itemb of data."+ item.file + ".split(',')\" style=\"cursor: pointer; color: red; \"\n\t\t");
                            previewhtml.Append("(click)=\"show" + item.file.FirstCharToUpper() + "file(data, itemb)\" nzTitle=\"" + item.name + "附件\" nzPlacement=\"bottomLeft\" nz-tooltip>\n\t\t 附件\n\t\t</span>\n\t\t</span>\n\t\t");
                        }
                        if (sindex == 0)
                        {
                            if (item.querytype == 11)
                            {
                                titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>\n");
                                titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>\n");
                            }
                            else
                            {
                                if (item.fileshowb)
                                {
                                    titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                    titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(item.fileshow))
                                    {
                                        titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>\n");
                                        titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>\n");
                                    }
                                    else
                                    {
                                        titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>\n");
                                        titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>\n");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (sindex == showlist.Count() - 1)
                            {
                                if (item.querytype == 11)
                                {
                                    titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>");
                                    titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>");
                                }
                                else
                                {
                                    if (item.fileshowb)
                                    {
                                        titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                        titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(item.fileshow))
                                        {
                                            titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>");
                                            titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>");
                                        }
                                        else
                                        {
                                            titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>");
                                            titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>");
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (item.querytype == 11)
                                {
                                    titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>\n");
                                    titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + previewhtml + "</td>\n");
                                }
                                else
                                {
                                    if (item.fileshowb)
                                    {
                                        titleshow.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                        titleshowb.Append("<td [nzAlign]=\"'center'\" " + leftxp + ">{{ show" + item.file.FirstCharToUpper() + "(data." + item.file + ")}}</td>\n");
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(item.fileshow))
                                        {
                                            titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>\n");
                                            titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + ">" + item.fileshow + "</td>\n");
                                        }
                                        else
                                        {
                                            titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>\n");
                                            titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\" " + leftxp + tooltip + ">{{ data." + item.file + " " + iszkcon + "}}</td>\n");
                                        }
                                    }
                                }
                            }
                        }
                        sindex++;
                    }
                    if (showlist.Count() <= 5)
                    {
                        titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.cTime | date:\"yyyy-MM-dd HH:mm:ss\" }}</td>\n");
                        titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.uTime === '0001-01-01 00:00:00'?'无': data.uTime| date:\"yyyy-MM-dd HH:mm:ss\" }}</td>\n");
                        titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.Remark }}</td>\n");
                        titleshow.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.status==1?\"否\":\"是\" }}</td>");

                        titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.cTime | date:\"yyyy-MM-dd HH:mm:ss\" }}</td>\n");
                        titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.uTime === '0001-01-01 00:00:00'?'无': data.uTime| date:\"yyyy-MM-dd HH:mm:ss\" }}</td>\n");
                        titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\">{{ data.Remark }}</td>\n");
                        titleshowb.Append("\t\t\t<td [nzAlign]=\"'center'\">待确认永久删除</td>");
                    }
                    #endregion

                    #region 设置编辑字段信息
                    StringBuilder addshow = new StringBuilder(); // 编辑界面字段显示定义
                    var writecount = generators.Count(o => o.isedit == true && o.file.ToUpper() != "Remark".ToUpper() && o.file.ToUpper() != "status".ToUpper() && o.file.ToUpper() != "Id".ToUpper() && o.file.ToUpper() != "ctime".ToUpper() && o.file.ToUpper() != "utime".ToUpper());
                    var list = generators.Where(o => o.isedit == true && o.isadditional == false).OrderBy(o => o.editindex);
                    var qeindex = 1;
                    var goalone = "true";
                    var eindex = 0;
                    StringBuilder jltmp = new StringBuilder();
                    StringBuilder mrtmp = new StringBuilder();
                    var aindex = 0; //针对ng13版本使用
                    foreach (var first in list)
                    {
                        if (!string.IsNullOrEmpty(first.customname))
                        {
                            first.name = first.customname;
                        }
                        if (first.querytype == 7)
                        {
                            var readonlystr = string.Empty;
                            if (first.isreadonly)
                            {
                                readonlystr = "[inputdisable]=\"true\"";
                            }
                            if (writecount <= 10)
                            {
                                first.inputw = 14;
                                first.labeldw = 5;
                            }
                            else
                            {
                                first.inputw = 7;
                                first.labeldw = 5;
                            }
                            if (writecount >= 10 && qeindex == 1)
                            {
                                goalone = "false";
                                addshow.Append("<nz-form-item>\n");
                            }
                            if (first.fileType.Contains("int"))
                            {
                                addshow.Append("<app-formminput " + readonlystr + " [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"" + goalone + "\" [inputtype]=\"'number'\"></app-formminput>\n");
                            }
                            if (first.fileType.Contains("double") || first.fileType.Contains("decimal"))
                            {
                                addshow.Append("<app-formminput " + readonlystr + " [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"" + goalone + "\"></app-formminput>\n");
                            }
                            if (first.fileType.Contains("varchar"))
                            {
                                var filelen = Convert.ToInt32(first.fileType.Split('(')[1].Split(')')[0]);
                                if (filelen >= 500)
                                {
                                    if (qeindex == 1)
                                    {
                                        addshow.Append("<app-formtextarea [rows]=\"" + first.rowspan + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"true\" ></app-formtextarea>");
                                    }
                                    if (qeindex == 2)
                                    {
                                        if (writecount >= 10)
                                        {
                                            addshow.Append("</nz-form-item>\n");
                                        }
                                        qeindex = 1;
                                        addshow.Append("<app-formtextarea [rows]=\"" + first.rowspan + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"true\" ></app-formtextarea>");
                                    }
                                }
                                else
                                {
                                    addshow.Append("<app-formminput " + readonlystr + " [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"" + goalone + "\" ></app-formminput>\n");
                                }
                            }
                            if (first.fileType.Contains("text"))
                            {
                                if (qeindex == 1)
                                {
                                    addshow.Append("<app-formtextarea [rows]=\"" + first.rowspan + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"true\" ></app-formtextarea>");
                                }
                                if (qeindex == 2)
                                {
                                    if (writecount >= 10)
                                    {
                                        addshow.Append("</nz-form-item>\n");
                                    }
                                    qeindex = 1;
                                    addshow.Append("<app-formtextarea [rows]=\"" + first.rowspan + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"  [goalone] = \"true\" ></app-formtextarea>");
                                }
                            }
                            if (first.fileType.Contains("datetime"))
                            {
                                addshow.Append("<app-formdatepicker [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder]= \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\" [goalone] = \"" + goalone + "\"></app-formdatepicker>\n");
                            }
                            if (writecount >= 10 && qeindex == 2)
                            {
                                addshow.Append("</nz-form-item>\n");
                            }
                            qeindex++;
                            if (writecount % 2 != 0 && qeindex == 2 && eindex == writecount - 1 && writecount >= 10)
                            {
                                addshow.Append("</nz-form-item>\n");
                            }
                            if (qeindex >= 3)
                            {
                                goalone = "true";
                                qeindex = 1;
                            }
                        }
                        else
                        {
                            if (writecount <= 10)
                            {
                                first.inputw = 14;
                                first.labeldw = 5;
                            }
                            else
                            {
                                first.inputw = 7;
                                first.labeldw = 5;
                            }

                            var querytypes = new[] { 1, 2, 3, 4 }; //下拉获取数据集
                            var querytypesb = new[] { 5, 6 }; //自动补全数组获取数据集
                            var sMode = "'default'";
                            if (first.querytype == 3 || first.querytype == 4) //多选下拉
                            {
                                sMode = "'multiple'";
                            }
                            var xls = string.Empty;
                            if (first.querytype == 1 || first.querytype == 3 || first.querytype == 8 || first.querytype == 9 || first.querytype==12)
                            {
                                xls = "Info.";
                            }
                            if (type == 1) //ng7版本
                            {
                                if (writecount >= 10 && qeindex == 1)
                                {
                                    goalone = "false";
                                    addshow.Append("<nz-form-item>\n");
                                }
                                if (querytypes.Any(o => o == first.querytype))
                                {
                                    addshow.Append("<app-formselect [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [sMode]=\"" + sMode + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" \n\t\t");
                                    addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                    addshow.Append("[Label]=\"'label'\" [Value]=\"'value'\" [list]=\"" + xls + first.file.FirstCharToUpper() + "List\" [showDefault]=\"false\" [goalone] = \"" + goalone + "\" (ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\">\n\t\t</app-formselect>\n");
                                }
                                else
                                {
                                    if (first.querytype == 8)
                                    {
                                        addshow.Append("<app-formradiogroup [goalone]=\"true\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                        addshow.Append("[formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" (changeTypeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\" [radioData]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formradiogroup>\n");
                                    }
                                    else if (first.querytype == 9)
                                    {
                                        addshow.Append("<app-formcheckboxgroup [goalone]=\"true\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                        addshow.Append("[placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\"\n\t\t");
                                        addshow.Append("[checkOptionsOne]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formcheckboxgroup>\n");
                                    }
                                    else if (first.querytype == 10)
                                    {
                                        addshow.Append("<app-formminput [goalone]=\"true\" [Required]=\"true\" [type]=\"2\" [HasFeedback]=\"true\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\"> \n\t\t");
                                        addshow.Append("<span class=\"insertcontent\">\n\t\t\t<app-poster [filename]=\"'" + first.file + "'\" (UploadEvent)=\"Upload" + first.file.FirstCharToUpper() + "($event)\" [uptitle]=\"'选择" + first.name + "上传'\"\n\t\t\t");
                                        addshow.Append("[uploadApi]=\"Info." + first.file + "Api\" [sId]=\"Info.Id\" [photodata]=\"Info." + first.file + "\"></app-poster>\n\t\t\t");
                                        addshow.Append("</span>\n\t\t\t</app-formminput>");
                                    }
                                    else if (first.querytype == 11)
                                    {
                                        addshow.Append("<app-formtextarea [rows]=\"1\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\"\n\t\t");
                                        addshow.Append("[controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\"  [formControlName] = \"'" + first.file + "'\"\n\t\t");
                                        addshow.Append("[formErrorName]= \"formErrors." + first.file + "\" [goalone]=\"true\">\n\t\t");
                                        addshow.Append("<span class=\"extendct\" style=\"float: left; width: 50px; position: absolute; \">\n\t\t");
                                        addshow.Append("<nz-upload [nzAction]=\"uploadApi" + first.file.FirstCharToUpper() + "\" [nzMultiple]=\"true\" [nzShowUploadList]=\"false\"\n\t\t");
                                        addshow.Append("[nzCustomRequest]=\"upload" + first.file.FirstCharToUpper() + "\" [nzAccept]=\"nzAccept\">\n\t\t");
                                        addshow.Append("<button nz-button type=\"button\" class=\"btn ant-btn-primary\"><i nz-icon\n\t\t\t");
                                        addshow.Append("nzType=\"upload\"></i><span>选择文件上传</span></button>\n\t\t</nz-upload>\n\t\t</span>\n\t\t");
                                        addshow.Append("<span class=\"extendc\" style=\"float: left; width: 50px; position: absolute; margin-left:25%;\"\n\t\t");
                                        addshow.Append("*ngIf=\"" + first.file.FirstCharToUpper() + "filelist.length > 0\">\n\t\t");
                                        addshow.Append("<button nz-button type=\"button\" class=\"btn ant-btn-primary\" (click)=\"downloadfile(" + first.file.FirstCharToUpper() + "filelist)\"><i nz-icon\n\t\t");
                                        addshow.Append("nzType=\"download\" nzTheme=\"outline\"></i>下载文件</button>\n\t\t</span>\n\t\t</app-formtextarea>");
                                    }
                                    else if (first.querytype == 12)
                                    {
                                        jltmp.Append(first.file.FirstCharToUpper() + "List = []; \n\t\t");
                                        mrtmp.Append("this." + first.file.FirstCharToUpper() + "List = this.Info." + first.file.FirstCharToUpper() + "List;\n\t\t");
                                        addshow.Append("<app-formselect [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [sMode]=\"" + sMode + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" \n\t\t");
                                        addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                        addshow.Append("[Label]=\"'label'\" [Value]=\"'value'\" [list]=\"" + first.file.FirstCharToUpper() + "List\" [showDefault]=\"false\" [goalone] = \"" + goalone + "\" (ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\">\n\t\t</app-formselect>\n");
                                    }
                                    else if (first.querytype == 13) //日期(年月日时分秒)
                                    {
                                        addshow.Append("<app-formdatepicker [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" ");
                                        addshow.Append("[goalone] = \"true\" [controlSpan]= \"" + first.inputw + "\" [labeltitle] = \"'" + first.name.Split('-')[0] + "'\" [placeholder] = \"'" + first.name.Split('-')[0] + "'\" ");
                                        addshow.Append("(ModelChangeEvent) = \""+ first.file.FirstCharToUpper()+ "Change($event)\" [Format] = \"'yyyy-MM-dd HH:mm:ss'\" [formControlName] = \"'" + first.file + "'\" ");
                                        addshow.Append("[formErrorName] = \"formErrors." + first.file + "\">");
                                        addshow.Append("</app-formdatepicker> ");

                                    }
                                    else if (first.querytype == 14) //日期(年月日)
                                    {
                                        addshow.Append("<app-formdatepicker [ShowTime]=\"false\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" ");
                                        addshow.Append("[goalone] = \"true\" [controlSpan]= \"" + first.inputw + "\" [labeltitle] = \"'" + first.name.Split('-')[0] + "'\" [placeholder] = \"'" + first.name.Split('-')[0] + "'\" ");
                                        addshow.Append("(ModelChangeEvent) = \"" + first.file.FirstCharToUpper() + "Change($event)\" [Format] = \"'yyyy-MM-dd'\" [formControlName] = \"'" + first.file + "'\" ");
                                        addshow.Append("[formErrorName] = \"formErrors." + first.file + "\">");
                                        addshow.Append("</app-formdatepicker> ");
                                    }
                                    else if (first.querytype == 15) //日期(月份)
                                    {
                                        addshow.Append("<app-formmmonth [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" ");
                                        addshow.Append("[placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" [goalone]=\"true\"></app-formmmonth>");

                                    }
                                    else if (first.querytype == 16) //日期(年份)
                                    {
                                        addshow.Append("<app-formmyear [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [inputtype]=\"''\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" ");
                                        addshow.Append("[labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" [goalone]=\"true\" [inputtype]= \"'number'\" ></app-formmyear>");
                                    }
                                    else
                                    {
                                        addshow.Append("<app-formautocomplete #auto" + first.file.FirstCharToUpper() + " [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"  [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                        addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                        addshow.Append("(ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\" (InputEvent)=\"onInput" + first.file.FirstCharToUpper() + "($event)\" [filteredOptions]=\"" + xls + first.file.FirstCharToUpper() + "List\" [goalone] = \"" + goalone + "\">\n\t\t");
                                        addshow.Append("</app-formautocomplete>\n\t\t");
                                    }
                                }
                                
                                if (writecount >= 10 && qeindex == 2)
                                {
                                    addshow.Append("</nz-form-item>\n");
                                }
                                qeindex++;
                                if (writecount % 2 != 0 && qeindex == 2 && eindex == writecount - 1 && writecount >= 10)
                                {
                                    addshow.Append("</nz-form-item>\n");
                                }
                                if (qeindex >= 3)
                                {
                                    goalone = "true";
                                    qeindex = 1;
                                }
                            }
                            if(type == 2) //ng13版本
                            {
                                if (writecount >= 10)
                                {
                                    if(aindex<writecount && (aindex + 1) <= writecount)
                                    {
                                        var Requireda = string.Empty;
                                        var Requiredb = string.Empty;
                                        var HasFeedbacka = string.Empty;
                                        var HasFeedbackb = string.Empty;
                                        var labeltitlea = string.Empty;
                                        var labeltitleb = string.Empty;
                                        var placeholdera = string.Empty;
                                        var placeholderb = string.Empty;
                                        var formControlNamea = string.Empty;
                                        var formControlNameb = string.Empty;
                                        var formErrorNamea = string.Empty;
                                        var formErrorNameb = string.Empty;
                                        var labelSpana = string.Empty;
                                        var labelSpanb = string.Empty;
                                        var controlSpana = string.Empty;
                                        var controlSpanb = string.Empty;
                                        var Disableda = string.Empty;
                                        var Disabledb = string.Empty;
                                        var inputdisablea = string.Empty;
                                        var inputdisableb = string.Empty;
                                        var rowsa = string.Empty;
                                        var rowsb = string.Empty;
                                        var Labela = string.Empty;
                                        var Labelb = string.Empty;
                                        var Valuea = string.Empty;
                                        var Valueb = string.Empty;
                                        var showDefaulta = string.Empty; //下拉是否显示请选择
                                        var showDefaultb = string.Empty;//下拉是否显示请选择
                                        var typea = string.Empty; //编辑类型
                                        var typeb = string.Empty; //编辑类型
                                        var radiodata = string.Empty;//单选框数据
                                        var radiodatb = string.Empty;//单选框数据
                                        var selectlista = string.Empty;//下拉单选数据
                                        var selectlistb = string.Empty;//下拉单选数据
                                        var selectmorelista = string.Empty;//下拉多选数据
                                        var selectmorelistb = string.Empty;//下拉多选数据
                                        var checkOptionsOnea = string.Empty; //复选框模式
                                        var checkOptionsOneb = string.Empty;//复选框模式
                                        var ModelaChangeEvent = string.Empty;//input值改变事件
                                        var ModelbChangeEvent = string.Empty;//input值改变事件
                                        var RadioaChangeEvent = string.Empty;//单选框值改变事件
                                        var RadiobChangeEvent = string.Empty;//单选框值改变事件
                                        var SelectaChangeEvent = string.Empty;//下拉框值改变事件
                                        var SelectbChangeEvent = string.Empty;//下拉框值改变事件
                                        var TextareaModelaChangeEvent = string.Empty;//下拉框值改变事件
                                        var TextarebModelaChangeEvent = string.Empty;//下拉框值改变事件
                                        var NewTimeaChangeEvent = string.Empty;//时间值改变事件
                                        var NewTimebChangeEvent = string.Empty;//时间值改变事件
                                        var CheckBoxaChangeEvent = string.Empty; //复选框值改变事件
                                        var CheckBoxbChangeEvent = string.Empty; //复选框值改变事件
                                        var AutoCompleteaEvent = string.Empty; //自动补全值改变事件
                                        var AutoCompletebEvent = string.Empty; //自动补全值改变事件
                                        var InputaEvent = string.Empty; //自动补全输入框值改变事件
                                        var InputbEvent = string.Empty; //自动补全输入框值改变事件
                                        var filteredOptionsa = string.Empty;//自动补全数据
                                        var filteredOptionsb = string.Empty;//自动补全数据
                                        var sModea = string.Empty; //下拉单选多选模式
                                        var sModeb = string.Empty;//下拉单选多选模式
                                        var TimeTypea = string.Empty;//时间模式
                                        var TimeTypeb = string.Empty;//时间模式
                                        var Formata = string.Empty;//日期格式
                                        var Formatb = string.Empty;//日期格式
                                        var ShowTimea = string.Empty;//是否显示日期时分秒
                                        var ShowTimeb = string.Empty;// 是否显示日期时分秒

                                        placeholdera = first.name.Split('-')[0];
                                        labeltitlea = first.name.Split('-')[0];
                                        formControlNamea = first.file;
                                        formErrorNamea = first.file;
                                        Requireda = "[Required]=\"" + first.isnullb.ToString().ToLower() + "\"";
                                        HasFeedbacka = "[HasFeedbacka]=\"" + first.isnullb.ToString().ToLower() + "\"";
                                        labelSpana = "[labelSpana]=\""+ first.labeldw + "\"";
                                        controlSpana = "[controlSpana]=\""+ first.inputw + "\"";

                                        if (first.querytype == 1 || first.querytype == 2)
                                        {
                                            typea = "[typea]=\"'select'\"";
                                            sModea = "[sModea]='default'";
                                            showDefaulta = "[showDefaulta]=\"true\"";
                                            selectlista = "[selectlista]=\"Info."+first.file.FirstCharToUpper()+"List\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            Labela = "[Labela]=\"'label'\"";
                                            Valuea = "[Valuea]=\"'value'\"";
                                            SelectaChangeEvent = "(SelectaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 3 || first.querytype == 4)
                                        {
                                            typea = "[typea]=\"'select'\"";
                                            sModea = "[sModea]='multiple'";
                                            showDefaulta = "[showDefaulta]=\"true\"";
                                            selectmorelista = "[selectmorelista]=\"Info." + first.file.FirstCharToUpper() + "List\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            Labela = "[Labela]=\"'label'\"";
                                            Valuea = "[Valuea]=\"'value'\"";
                                            SelectaChangeEvent = "(SelectaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 5 || first.querytype == 6)
                                        {
                                            typea = "[typea]=\"'autocomplete'\"";
                                            AutoCompleteaEvent = "(AutoCompleteaEvent)=\"select"+first.file.FirstCharToUpper()+"($event)\"";
                                            InputaEvent = "(InputaEvent)=\"onInputfirst" + file.FirstCharToUpper() + "Change($event)\"";
                                            filteredOptionsa = "[filteredOptionsa]=\"filteredOptions"+ first.file.FirstCharToUpper() + "\"";
                                        }
                                        if (first.querytype == 7)
                                        {
                                            typea = "[typea]=\"'input'\"";
                                            inputdisablea = "[inputdisablea]=\"" + first.isreadonly + "\"";
                                            ModelaChangeEvent = "(ModelaChangeEvent)=\""+ first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 8)
                                        {
                                            typea = "[typea]=\"'radio'\"";
                                            radiodata = "[radioDataa]=\"Info."+ first.file.FirstCharToUpper()+ "List\" ";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            RadioaChangeEvent = "(RadioaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 9)
                                        {
                                            typea = "[typea]=\"'checkbox'\"";
                                            checkOptionsOnea = "[checkOptionsOnea]=\"Info." + first.file.FirstCharToUpper() + "List\" ";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            CheckBoxaChangeEvent = "(CheckBoxaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 13)
                                        {
                                            typea = "[typea]=\"'newtime'\"";
                                            TimeTypea = "[TimeTypea]=\"date\"";
                                            Formata = "[Formata]=\"'yyyy-MM-dd HH:mm:ss'\"";
                                            ShowTimea = "[ShowTimea]=\"true\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            NewTimeaChangeEvent = "(NewTimeaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 14)
                                        {
                                            typea = "[typea]=\"'newtime'\"";
                                            TimeTypea = "[TimeTypea]=\"date\"";
                                            Formata = "[Formata]=\"'yyyy-MM-dd'\"";
                                            ShowTimea = "[ShowTimea]=\"true\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            NewTimeaChangeEvent = "(NewTimeaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 15)
                                        {
                                            typea = "[typea]=\"'newtime'\"";
                                            TimeTypea = "[TimeTypea]=\"month\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            NewTimeaChangeEvent = "(NewTimeaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 16)
                                        {
                                            typea = "[typea]=\"'newtime'\"";
                                            TimeTypea = "[TimeTypea]=\"year\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            NewTimeaChangeEvent = "(NewTimeaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if (first.querytype == 17)
                                        {
                                            typea = "[typea]=\"'textarea'\"";
                                            Disableda = "[Disableda]=\"" + first.isreadonly + "\"";
                                            rowsa = "[rowsa]=\""+first.row+"\"";
                                            TextareaModelaChangeEvent = "(TextareaModelaChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\"";
                                        }
                                        if ((aindex + 1) <= writecount)
                                        {
                                            placeholderb = list.Skip(aindex).Take(1).FirstOrDefault().name.Split('-')[0];
                                            labeltitleb = list.Skip(aindex).Take(1).FirstOrDefault().name.Split('-')[0];
                                            formControlNameb = list.Skip(aindex).Take(1).FirstOrDefault().file;
                                            formErrorNameb = list.Skip(aindex).Take(1).FirstOrDefault().file;
                                            Requiredb = "[Requiredb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isnullb.ToString().ToLower() + "\"";
                                            HasFeedbackb = "[HasFeedbackb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isnullb.ToString().ToLower() + "\"";
                                            labelSpanb = "[labelSpanb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().labeldw + "\"";
                                            controlSpanb = "[controlSpanb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().inputw + "\"";
                                            aindex += 1;
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 1 || list.Skip(aindex).Take(1).FirstOrDefault().querytype == 2)
                                            {
                                                typeb = "[typeb]=\"'select'\"";
                                                sModeb = "'default'";
                                                showDefaultb = "[showDefaultb]=\"true\"";
                                                selectlistb = "[selectlistb]=\"Info." + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "List\"";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                Labelb = "[Labelb]=\"'label'\"";
                                                Valueb = "[Valueb]=\"'value'\"";
                                                SelectbChangeEvent = "(SelectbChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 3 || list.Skip(aindex).Take(1).FirstOrDefault().querytype == 4)
                                            {
                                                typeb = "[typea]=\"'select'\"";
                                                sModeb = "[sModea]='multiple'";
                                                showDefaultb = "[showDefaultb]=\"true\"";
                                                selectmorelistb = "[selectmorelistb]=\"Info." + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "List\"";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                Labelb = "[Labelb]=\"'label'\"";
                                                Valueb = "[Valueb]=\"'value'\"";
                                                SelectbChangeEvent = "(SelectbChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 7)
                                            {
                                                typeb = "[typeb]=\"'input'\"";
                                                inputdisableb = "[inputdisableb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                ModelbChangeEvent = "(ModelbChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 8)
                                            {
                                                typeb = "[typeb]=\"'radio'\"";
                                                radiodatb = "[radioDataa]=\"Info." + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "List\" ";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                RadiobChangeEvent = "(RadiobChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 9)
                                            {
                                                typeb = "[typea]=\"'checkbox'\"";
                                                checkOptionsOneb = "[checkOptionsOneb]=\"Info." + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "List\" ";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                CheckBoxbChangeEvent = "(CheckBoxbChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 13)
                                            {
                                                typeb = "[typeb]=\"'newtime'\"";
                                                TimeTypeb = "date";
                                                Formatb = "'yyyy-MM-dd HH:mm:ss'";
                                                ShowTimeb = "[ShowTimeb]=\"true\"";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                NewTimebChangeEvent = "(NewTimebChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 14)
                                            {
                                                typeb = "[typeb]=\"'newtime'\"";
                                                TimeTypeb = "date";
                                                Formatb = "'yyyy-MM-dd'";
                                                ShowTimeb = "[ShowTimeb]=\"false\"";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                NewTimebChangeEvent = "(NewTimebChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 15)
                                            {
                                                typeb = "[typeb]=\"'newtime'\"";
                                                TimeTypeb = "month";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                NewTimebChangeEvent = "(NewTimeaChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 16)
                                            {
                                                typeb = "[typeb]=\"'newtime'\"";
                                                TimeTypeb = "year";
                                                Disabledb = "[Disabledb]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().isreadonly + "\"";
                                                NewTimebChangeEvent = "(NewTimeaChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                            if (list.Skip(aindex).Take(1).FirstOrDefault().querytype == 17)
                                            {
                                                typeb = "[typeb]=\"'textarea'\"";
                                                rowsa = "[rowsa]=\"" + list.Skip(aindex).Take(1).FirstOrDefault().row + "\"";
                                                TextarebModelaChangeEvent = "(TextarebModelaChangeEvent)=\"" + list.Skip(aindex).Take(1).FirstOrDefault().file.FirstCharToUpper() + "Change($event)\"";
                                            }
                                        }

                                        addshow.Append("<app-formmcombination "+ inputdisablea + " "+ Labelb + " "+ Valueb + " "+ selectlistb + " "+ showDefaultb + " ");
                                        addshow.Append("[typea]=\""+ typea + "\" [typeb]=\""+ typeb + "\" [parentInstance]=\"this\" [labelSpana]=\"4\" [controlSpana]=\"5\" [labeltitlea]=\"'填报人电话'\"");
                                        addshow.Append("[placeholdera] = \"'填报人电话'\" [formControlNamea] = \"'mobile'\" [formErrorNamea] = \"formErrors.mobile\" [labelSpanb] = \"6\" [controlSpanb] = \"7\" ");
                                        addshow.Append("[labeltitleb] = \"'所属企业'\" [placeholderb] = \"'所属企业'\" [formControlNameb] = \"'cId'\" [formErrorNameb] = \"formErrors.reviewer\"></app-formmcombination> ");
                                    }
                                    else
                                    {

                                    }
                                }
                                else
                                {
                                    goalone = "true";
                                    if (querytypes.Any(o => o == first.querytype))
                                    {
                                        addshow.Append("<app-formselect [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [sMode]=\"" + sMode + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" \n\t\t");
                                        addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                        addshow.Append("[Label]=\"'label'\" [Value]=\"'value'\" [list]=\"" + xls + first.file.FirstCharToUpper() + "List\" [showDefault]=\"false\" [goalone] = \"" + goalone + "\" (ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\">\n\t\t</app-formselect>\n");
                                    }
                                    else
                                    {
                                        if (first.querytype == 8)
                                        {
                                            addshow.Append("<app-formradiogroup [goalone]=\"true\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                            addshow.Append("[formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" (changeTypeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\" [radioData]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formradiogroup>\n");
                                        }
                                        else if (first.querytype == 9)
                                        {
                                            addshow.Append("<app-formcheckboxgroup [goalone]=\"true\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                            addshow.Append("[placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\"\n\t\t");
                                            addshow.Append("[checkOptionsOne]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formcheckboxgroup>\n");
                                        }
                                        else if (first.querytype == 10)
                                        {
                                            addshow.Append("<app-formminput [goalone]=\"true\" [Required]=\""+ first.isnullb.ToString().ToLower() + "\" [type]=\"2\" [HasFeedback]=\""+ first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\"> \n\t\t");
                                            addshow.Append("<span class=\"insertcontent\">\n\t\t\t<app-poster [filename]=\"'" + first.file + "'\" (UploadEvent)=\"Upload" + first.file.FirstCharToUpper() + "($event)\" [uptitle]=\"'选择" + first.name + "上传'\"\n\t\t\t");
                                            addshow.Append("[uploadApi]=\"Info." + first.file + "Api\" [sId]=\"Info.Id\" [photodata]=\"Info." + first.file + "\"></app-poster>\n\t\t\t");
                                            addshow.Append("</span>\n\t\t\t</app-formminput>");
                                        }
                                        else if (first.querytype == 11)
                                        {
                                            addshow.Append("<app-formtextarea [rows]=\"1\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\"\n\t\t");
                                            addshow.Append("[controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\"  [formControlName] = \"'" + first.file + "'\"\n\t\t");
                                            addshow.Append("[formErrorName]= \"formErrors." + first.file + "\" [goalone]=\"true\">\n\t\t");
                                            addshow.Append("<span class=\"extendct\" style=\"float: left; width: 50px; position: absolute; \">\n\t\t");
                                            addshow.Append("<nz-upload [nzAction]=\"uploadApi" + first.file.FirstCharToUpper() + "\" [nzMultiple]=\"true\" [nzShowUploadList]=\"false\"\n\t\t");
                                            addshow.Append("[nzCustomRequest]=\"upload" + first.file.FirstCharToUpper() + "\" [nzAccept]=\"nzAccept\">\n\t\t");
                                            addshow.Append("<button nz-button type=\"button\" class=\"btn ant-btn-primary\"><i nz-icon\n\t\t\t");
                                            addshow.Append("nzType=\"upload\"></i><span>选择文件上传</span></button>\n\t\t</nz-upload>\n\t\t</span>\n\t\t");
                                            addshow.Append("<span class=\"extendc\" style=\"float: left; width: 50px; position: absolute; margin-left:25%;\"\n\t\t");
                                            addshow.Append("*ngIf=\"" + first.file.FirstCharToUpper() + "filelist.length > 0\">\n\t\t");
                                            addshow.Append("<button nz-button type=\"button\" class=\"btn ant-btn-primary\" (click)=\"downloadfile(" + first.file.FirstCharToUpper() + "filelist)\"><i nz-icon\n\t\t");
                                            addshow.Append("nzType=\"download\" nzTheme=\"outline\"></i>下载文件</button>\n\t\t</span>\n\t\t</app-formtextarea>");
                                        }
                                        else if (first.querytype == 12)
                                        {
                                            jltmp.Append(first.file.FirstCharToUpper() + "List = []; \n\t\t");
                                            mrtmp.Append("this." + first.file.FirstCharToUpper() + "List = this.Info." + first.file.FirstCharToUpper() + "List;\n\t\t");
                                            addshow.Append("<app-formselect [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [sMode]=\"" + sMode + "\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" \n\t\t");
                                            addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                            addshow.Append("[Label]=\"'label'\" [Value]=\"'value'\" [list]=\"" + first.file.FirstCharToUpper() + "List\" [showDefault]=\"false\" [goalone] = \"" + goalone + "\" (ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\">\n\t\t</app-formselect>\n");
                                        }
                                        else if (first.querytype == 13) //日期(年月日时分秒)
                                        {
                                            addshow.Append("<app-formdatepicker [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" ");
                                            addshow.Append("[goalone] = \""+ goalone + "\" [controlSpan]= \"" + first.inputw + "\" [labeltitle] = \"'" + first.name.Split('-')[0] + "'\" [placeholder] = \"'" + first.name.Split('-')[0] + "'\" ");
                                            addshow.Append("(ModelChangeEvent) = \"" + first.file.FirstCharToUpper() + "Change($event)\" [Format] = \"'yyyy-MM-dd HH:mm:ss'\" [formControlName] = \"'" + first.file + "'\" ");
                                            addshow.Append("[formErrorName] = \"formErrors." + first.file + "\">");
                                            addshow.Append("</app-formdatepicker> ");

                                        }
                                        else if (first.querytype == 14) //日期(年月日)
                                        {
                                            addshow.Append("<app-formdatepicker [ShowTime]=\"false\" [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" ");
                                            addshow.Append("[goalone] = \"" + goalone + "\" [controlSpan]= \"" + first.inputw + "\" [labeltitle] = \"'" + first.name.Split('-')[0] + "'\" [placeholder] = \"'" + first.name.Split('-')[0] + "'\" ");
                                            addshow.Append("(ModelChangeEvent) = \"" + first.file.FirstCharToUpper() + "Change($event)\" [Format] = \"'yyyy-MM-dd'\" [formControlName] = \"'" + first.file + "'\" ");
                                            addshow.Append("[formErrorName] = \"formErrors." + first.file + "\">");
                                            addshow.Append("</app-formdatepicker> ");
                                        }
                                        else if (first.querytype == 15) //日期(月份)
                                        {
                                            addshow.Append("<app-formmmonth [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" ");
                                            addshow.Append("[placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" [goalone]=\"" + goalone + "\"></app-formmmonth>");

                                        }
                                        else if (first.querytype == 16) //日期(年份)
                                        {
                                            addshow.Append("<app-formmyear [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [inputtype]=\"''\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" ");
                                            addshow.Append("[labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [placeholder]=\"'" + first.name.Split('-')[0] + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" [goalone]=\"" + goalone + "\" [inputtype]= \"'number'\" ></app-formmyear>");
                                        }
                                        else
                                        {
                                            addshow.Append("<app-formautocomplete #auto" + first.file.FirstCharToUpper() + " [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"  [Required]=\"" + first.isnullb.ToString().ToLower() + "\" [HasFeedback]=\"" + first.isnullb.ToString().ToLower() + "\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                            addshow.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [formErrorName] = \"formErrors." + first.file + "\"\n\t\t");
                                            addshow.Append("(ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\" (InputEvent)=\"onInput" + first.file.FirstCharToUpper() + "($event)\" [filteredOptions]=\"" + xls + first.file.FirstCharToUpper() + "List\" [goalone] = \"" + goalone + "\">\n\t\t");
                                            addshow.Append("</app-formautocomplete>\n\t\t");
                                        }
                                    }
                                }
                            } 
                            
                        }
                        eindex++;
                    }
                    #endregion

                    #region 设置合并列字段显示信息
                    StringBuilder moreqtmp = new StringBuilder();
                    var hblist = generators.Any(o => o.isadditional == true);
                    if (hblist)
                    {
                        var maxrowspan = generators.Max(o => o.rowspan);
                        var rowdata = generators.OrderBy(o => o.titleindex).GroupBy(o => o.row);
                        moreqtmp.Append("<ng-template class=\"querythead\" nz-virtual-scroll ngFor let-data [ngForOf]=\"columnlist\" let-index=\"index\">\n");
                        var rindex = 0;
                        foreach (var item in rowdata)
                        {
                            moreqtmp.Append("\t\t\t<tr>\n");
                            var tcols = 0;
                            foreach (var itemb in item)
                            {
                                var leftwd = "";
                                if (itemb.shiftleft > 0)
                                {
                                    leftwd = "nzLeft=\"" + itemb.shiftleft + "px";
                                }
                                if (rindex == 0 && tcols==0)
                                {
                                    moreqtmp.Append("\t\t\t<th rowspan=\"" + maxrowspan + "\" nzLeft=\"0px\" nzWidth=\"50px\" [nzAlign]=\"'center'\" nzShowExpand nzShowCheckbox [(nzChecked)] = \"allChecked\" (nzCheckedChange) = \"checkAll($event)\">序号</th>\n");
                                }
                                moreqtmp.Append("\t\t\t<th rowspan=\"" + itemb.rowspan + "\" colspan=\"" + itemb.colspan + "\" " + leftwd + " [nzAlign]=\"'center'\">" + itemb.name.Split('-')[0] + "</th>\n");
                                if (rindex ==0 && tcols == item.Count() - 1)
                                {
                                    moreqtmp.Append("\t\t\t<th rowspan=\"" + maxrowspan + "\" [nzAlign]=\"'center'\">操作</th>\n");
                                }
                                tcols++;
                            }
                            moreqtmp.Append("\t\t\t</tr>");
                            rindex++;
                        }
                        moreqtmp.Append("</ng-template>");
                    }
                    #endregion

                    #region 设置多条件查询字段信息
                    if (generators.Any(o => o.isquerymore))
                    {
                        writecount = generators.Count(o => o.isquery == true && o.file.ToUpper() != "Remark".ToUpper() && o.file.ToUpper() != "status".ToUpper() && o.file.ToUpper() != "Id".ToUpper() && o.file.ToUpper() != "ctime".ToUpper() && o.file.ToUpper() != "utime".ToUpper());
                        list = generators.Where(o => o.isquery == true && o.isadditional == false).OrderBy(o => o.queryindex);
                        qeindex = 1;
                        goalone = "true";
                        eindex = 0;
                        foreach (var first in list)
                        {
                            if (!string.IsNullOrEmpty(first.customname))
                            {
                                first.name = first.customname;
                            }
                            if (first.querytype == 7)
                            {
                                if (writecount <= 10)
                                {
                                    first.inputw = 14;
                                    first.labeldw = 5;
                                }
                                else
                                {
                                    first.inputw = 7;
                                    first.labeldw = 5;
                                }
                                if (writecount >= 10 && qeindex == 1)
                                {
                                    goalone = "false";
                                    querymore.Append("<nz-form-item>\n");
                                }
                                if (first.fileType.Contains("int"))
                                {
                                    querymore.Append("<app-formminput [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\" [inputtype]=\"'number'\"></app-formminput>\n");
                                }
                                if (first.fileType.Contains("double"))
                                {
                                    querymore.Append("<app-formminput [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\" [inputtype]=\"'number'\"></app-formminput>\n");
                                }
                                if (first.fileType.Contains("varchar") || first.fileType.Contains("text"))
                                {
                                    var filelen = Convert.ToInt32(first.fileType.Split('(')[1].Split(')')[0]);
                                    if (filelen >= 500 || first.fileType.Contains("text"))
                                    {
                                        if (qeindex == 1)
                                        {
                                            addshow.Append("<app-formtextarea [Required]=\"false\" [HasFeedback]=\"false\"  [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\"></app-formtextarea>");
                                        }
                                        if (qeindex == 2)
                                        {
                                            if (writecount >= 10)
                                            {
                                                addshow.Append("</nz-form-item>\n");
                                            }
                                            qeindex = 1;
                                            addshow.Append("<app-formtextarea [Required]=\"false\" [HasFeedback]=\"false\"  [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\" ></app-formtextarea>");
                                        }
                                    }
                                    else
                                    {
                                        querymore.Append("<app-formminput [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\" ></app-formminput>\n");
                                    }
                                }
                                if (first.fileType.Contains("datetime"))
                                {
                                    querymore.Append("<app-formdatepicker [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t[placeholder]= \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" [goalone] = \"" + goalone + "\"></app-formdatepicker>\n");
                                }
                                if (writecount >= 10 && qeindex == 2)
                                {
                                    querymore.Append("</nz-form-item>\n");
                                }
                                qeindex++;
                                if (writecount % 2 != 0 && qeindex == 2 && eindex == writecount - 1)
                                {
                                    querymore.Append("</nz-form-item>\n");
                                }
                                if (qeindex >= 3)
                                {
                                    goalone = "true";
                                    qeindex = 1;
                                }
                            }
                            else
                            {
                                if (writecount <= 10)
                                {
                                    first.inputw = 14;
                                    first.labeldw = 5;
                                }
                                else
                                {
                                    first.inputw = 7;
                                    first.labeldw = 5;
                                }

                                var querytypes = new[] { 1, 2, 3, 4 }; //下拉获取数据集
                                var querytypesb = new[] { 5, 6 }; //自动补全数组获取数据集
                                var sMode = "'default'";
                                if (first.querytype == 3 || first.querytype == 4) //多选下拉
                                {
                                    sMode = "'multiple'";
                                }
                                if (writecount >= 10 && qeindex == 1)
                                {
                                    goalone = "false";
                                    querymore.Append("<nz-form-item>\n");
                                }
                                var qis = string.Empty;
                                if (first.querytype == 1 || first.querytype == 3 || first.querytype == 5)
                                {
                                    qis = "Info.";
                                }
                                if (querytypes.Any(o => o == first.querytype))
                                {
                                    querymore.Append("<app-formselect [labeltitle]=\"'" + first.name.Split('-')[0] + "'\" [sMode]=\"" + sMode + "\" [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" \n\t\t");
                                    querymore.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\" \n\t\t");
                                    querymore.Append("[Label]=\"'label'\" [Value]=\"'value'\" [list]=\"" + qis + first.file.FirstCharToUpper() + "List\" [showDefault]=\"true\" [goalone] = \"" + goalone + "\" (ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\">\n\t\t</app-formselect>\n");
                                }
                                else
                                {
                                    var xls = string.Empty;
                                    if (first.querytype == 1 || first.querytype == 3)
                                    {
                                        xls = "Info.";
                                    }
                                    if (first.querytype == 8)
                                    {
                                        querymore.Append("<app-formradiogroup [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name + "'\"\n\t\t");
                                        querymore.Append("[formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\" (changeTypeEvent)=\"change" + first.file.FirstCharToUpper() + "($event)\" [radioData]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formradiogroup>\n\t\t");
                                    }
                                    else if (first.querytype == 9)
                                    {
                                        querymore.Append("<app-formcheckboxgroup [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name + "'\"\n\t\t");
                                        querymore.Append("[placeholder]=\"'" + first.name + "'\" [formControlName]=\"'" + first.file + "'\" [formErrorName]=\"formErrors." + first.file + "\"\n\t\t");
                                        querymore.Append("[checkOptionsOne]=\"" + xls + first.file.FirstCharToUpper() + "List\">\n\t\t</app-formcheckboxgroup>\n\t\t");
                                    }
                                    else
                                    {
                                        querymore.Append("<app-formautocomplete  #auto" + first.file.FirstCharToUpper() + " [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"  [Required]=\"false\" [HasFeedback]=\"false\" [parentInstance]=\"this\" [labelSpan]=\"" + first.labeldw + "\" [controlSpan]=\"" + first.inputw + "\" [labeltitle]=\"'" + first.name.Split('-')[0] + "'\"\n\t\t");
                                        querymore.Append("[placeholder] = \"'" + first.name.Split('-')[0] + "'\" [formControlName] = \"'" + first.file + "'\"\n\t\t");
                                        querymore.Append("(ModelChangeEvent)=\"" + first.file.FirstCharToUpper() + "Change($event)\" (InputEvent)=\"onInput" + first.file.FirstCharToUpper() + "($event)\" [filteredOptions]=\"" + xls + first.file.FirstCharToUpper() + "List\" [goalone] = \"" + goalone + "\">\n\t\t");
                                        querymore.Append("</app-formautocomplete>\n\t\t");
                                    }
                                }
                                if (writecount >= 10 && qeindex == 2)
                                {
                                    querymore.Append("</nz-form-item>\n");
                                }
                                qeindex++;
                                if (qeindex >= 3)
                                {
                                    goalone = "true";
                                    qeindex = 1;
                                }
                            }
                            eindex++;
                        }

                        querymore.Append("</form>\n");
                        querymore.Append("</app-searchoperation>");
                    }
                    #endregion

                    #region 设置资源操作信息
                    StringBuilder boperation = new StringBuilder();
                    if (generators.Any(o => !string.IsNullOrEmpty(o.oresources)))
                    {
                        var oresources = generators[0].oresources.Split(',');
                        var ind = 0;
                        foreach (var item in oresources)
                        {
                            if (string.IsNullOrEmpty(item))
                            {
                                boperation.Append("<button nz-button nz-dropdown nzType=\"primary\" [nzSize]=\"'small'\" [nzDropdownMenu]=\"menu1\"><span>操作</span>\n\t<i nz-icon nzType=\"down\"></i>\n\t</button>\n\t<nz-dropdown-menu #menu1=\"nzDropdownMenu\">\n\t");
                                boperation.Append("<ul nz-menu>\n\t");
                                ind++;
                                continue;
                            }
                            var label = item.Split('-')[0];
                            var vv = item.Split('-')[1];
                            if (ind == 0)
                            {
                                boperation.Append("<button nz-button nz-dropdown nzType=\"primary\" [nzSize]=\"'small'\" [nzDropdownMenu]=\"menu1\"><span>操作</span>\n\t<i nz-icon nzType=\"down\"></i>\n\t</button>\n\t<nz-dropdown-menu #menu1=\"nzDropdownMenu\">\n\t");
                                boperation.Append("<ul nz-menu>\n\t");
                                boperation.Append("<li nz-menu-item (click)=\"Confirm(data, " + vv + ", '" + label + "',$event)\">\n\t<a>" + label + "</a>\n\t</li>\n\t");
                            }
                            else if (ind == oresources.Length - 1)
                            {
                                boperation.Append("<li nz-menu-item (click)=\"Confirm(data, " + vv + ", '" + label + "',$event)\">\n\t<a>" + label + "</a>\n\t</li>\n\t");
                                boperation.Append("<li nz-menu-item (click)=\"showEdit(data,$event)\">\n\t<a>修改</a>\n\t</li>\n\t");
                                boperation.Append("<li nz-menu-item (click)=\"delete(data,$event)\">\n\t<a>删除</a>\n\t</li>\n\t");
                                boperation.Append("</ul>\n\t</nz-dropdown>");
                            }
                            else
                            {
                                boperation.Append("<li nz-menu-item (click)=\"Confirm(data, " + vv + ", '" + label + "',$event)\">\n\t<a>" + label + "</a>\n\t</li>\n\t");
                            }
                            ind++;
                        }
                    }
                    else
                    {
                        boperation.Append("<button nz-button nzType=\"primary\" [nzSize]=\"'small'\" (click)=\"showEdit(data,$event)\">修改</button>\n\t\t\t");
                        boperation.Append("<button nz-button nzType=\"primary\" [nzSize]=\"'small'\" (click)=\"delete(data,$event)\" style=\"margin-left:6px;\">删除</button>\n\t\t\t");
                    }
                    #endregion

                    #region 设置文件预览信息
                    StringBuilder previewtmp = new StringBuilder();
                    var havepreview = generators.Any(o => o.querytype == 11);
                    if (havepreview)
                    {
                        var fileyla = string.Empty;
                        var fileylb = string.Empty;
                        if (type == 2)
                        {
                            fileyla = "<ng-container *nzDrawerContent>";
                            fileylb = "</ng-container>";
                        }
                        previewtmp.Append("<nz-drawer [nzWidth]=\"'60%'\" [nzVisible]=\"visible\" nzPlacement=\"right\" nzTitle=\"" + module + "附件信息\" (nzOnClose)=\"close()\">\n\t\t"+ fileyla + "<p>\n\t\t");
                        previewtmp.Append("<button type=\"button\" style=\"border: 0; color: #ffffff;\" class=\"btn ant-btn-primary dropdown-toggle\"\n\t\t");
                        previewtmp.Append("data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" (click)=\"close()\">\n\t\t");
                        previewtmp.Append("<span><i nz-icon nzType=\"rollback\" nzTheme=\"outline\"></i>关闭</span>\n\t\t</button>\n\t\t");
                        previewtmp.Append("<button type=\"button\" style=\"border: 0; color: #ffffff;margin-left:20px;\" class=\"btn ant-btn-primary dropdown-toggle\"\n\t\t");
                        previewtmp.Append("data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" (click)=\"downloadfile()\">\n\t\t");
                        previewtmp.Append("<span><i nz-icon nzType=\"download\" nzTheme=\"outline\"></i>下载文件</span>\n\t\t</button>\n\t\t");
                        previewtmp.Append("<nz-divider [nzText]=\"curroutename\" ng-show=\"curroutename !== ''\" style=\"color: red;\"></nz-divider>\n\t\t");
                        previewtmp.Append("<iframe frameborder=0 scrolling=\"auto\" [height]=\"heightValue\" width=\"100%\" [src]=\"filePath\"></iframe>\n\t\t</p>\n\t\t"+ fileylb + "</nz-drawer>\n\t\t");
                    }
                    #endregion

                    var entityname = model.FirstCharToUpper();

                    string json = FileUtil.ReadFile(file);
                    json = AesEncryptionUtil.AESDecrypt(json, out var msga);
                    if (!msga.IsNull())
                    {
                        result.msg = ImplementResult.Templatefailed.GetRemark();
                        return result;
                    }
                    var ismtimp = "";
                    if (generators.Any(o => o.isadditional))
                    {
                        ismtimp = " [ishbcolum]=\"true\" ";
                    }
                    string newjson = json.Replace("htmltemplate", titleshow.ToString())
                    .Replace("hszhtl", titleshowb.ToString())
                    .Replace("系统", module)
                    .Replace("boperation", boperation.ToString())
                    .Replace("ismtimp", ismtimp)
                    .Replace("showzk", showzk)
                    .Replace("zklengx", zklengx.ToString())
                    .Replace("hbltmp", hbltmp)
                    .Replace("nzScrotmp", nzScrotmp)
                    .Replace("imtmp", imtmp)
                    .Replace("moreqtmp", moreqtmp.ToString())
                    .Replace("impzj", impzj.ToString())
                    .Replace("morequery", morequery)
                    //.Replace("querymore", querymore.ToString())
                    .Replace("previewtmp", previewtmp.ToString())
                    .Replace("qtemp", query.ToString());
                    if (!FileUtil.ExistsDir(generatorpath))
                    {
                        FileUtil.CreateDirectory(generatorpath);
                    }
                    if (!FileUtil.Exists(generatorpath +"\\" + filename))
                    {
                        FileUtil.WriteFile(generatorpath, filename, newjson);
                        var modulename = $"{directoryname}.module.ts";
                        var modulepath = string.Empty;
                        if (type == 1)
                        {
                             modulepath = newpath + "webng\\src\\app\\modules\\" + directoryname + "\\" + modulename;
                        }
                        if (type == 2)
                        {
                             modulepath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname + "\\" + modulename;
                        }
                        string newmodule = string.Empty;
                        if (module.Contains("管理"))
                        {
                            newmodule = module;
                        }
                        else
                        {
                            newmodule = module + "管理";
                        }
                        if (!string.IsNullOrEmpty(generators[0].breadcrumbname))
                        {
                            newmodule = generators[0].breadcrumbname;
                        }
                        if (FileUtil.Exists(modulepath)) //对应组件模块已经存在
                        {
                            //添加组件到对应模块中
                            string modulejson = FileUtil.ReadFile(modulepath);
                            Regex f = new Regex("]");
                            string thname = $", {entityname}Component]";
                            modulejson = f.Replace(modulejson, thname, 1);
                            string adddata = ";\nimport { " + entityname + "Component } from './" + model + "'";
                            modulejson = modulejson.Insert(modulejson.LastIndexOf(';'), adddata).TrimEnd(';');
                            var modulemkpath = string.Empty;
                            if (type == 1)
                            {
                                 modulemkpath = newpath + "webng\\src\\app\\modules\\" + directoryname;
                            }
                            if (type == 2)
                            {
                                 modulemkpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname;
                            }
                            if (FileUtil.Exists(modulemkpath + "\\" + modulename))
                            {
                                FileUtil.WriteFile(modulemkpath, modulename, modulejson);
                            }

                            //添加组件到对应路由模块中
                            string routename = $"{directoryname}-routing.module.ts";
                            var routepath = string.Empty;
                            if (type == 1)
                            {
                                 routepath = newpath + "webng\\src\\app\\modules\\" + directoryname + "\\" + routename;
                            }
                            if (type == 2)
                            {
                                 routepath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname + "\\" + routename;
                            }
                            string routejson = FileUtil.ReadFile(routepath);

                            var prindex = routejson.IndexOf("path: '', redirectTo");
                            if (prindex == -1)
                            {
                                prindex = routejson.IndexOf("path:'',redirectTo");
                            }
                            thname = "path: '" + model + "', component: " + entityname + "Component, data:\n\t{ moduletitle: '" + newmodule + "', module: 'index/" + directoryname + "/" + model + "', power: 'show', keep: true, breadcrumb: '" + newmodule + "' },\n\tcanActivate: [AuthGuardService]},\n\t{";
                            routejson = routejson.Insert(prindex, thname);
                            adddata = "import { " + entityname + "Component } from './" + model + "';\n";
                            routejson = routejson.Insert(routejson.IndexOf("const") - 2, adddata);
                            var routemkpath = string.Empty;
                            if (type == 1)
                            {
                                 routemkpath = newpath + "webng\\src\\app\\modules\\" + directoryname;
                            }
                            if (type == 2)
                            {
                                 routemkpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname;
                            }
                            if (FileUtil.Exists(routemkpath + "\\" + routename))
                            {
                                FileUtil.WriteFile(routemkpath, routename, routejson);
                            }
                        }
                        else //没有创建对应组件模块信息
                        {
                            //创建模块根组件
                            string moduletemplate = FileUtil.ReadFile(fileNameModule);
                            moduletemplate = AesEncryptionUtil.AESDecrypt(moduletemplate, out msga);
                            if (!msga.IsNull())
                            {
                                result.msg = ImplementResult.Templatefailed.GetRemark();
                                return result;
                            }
                            var tmproota = string.Empty;
                            var tmprootb = string.Empty;
                            if (type == 1)
                            {
                                tmproota = "import { NgZorroAntdModule } from 'ng-zorro-antd';\n\t";
                                tmprootb = "// tslint:disable-next-line: deprecation\n\tNgZorroAntdModule.forRoot(),\n\t";
                            }
                            moduletemplate = moduletemplate.Replace("table", entityname).Replace("template", model).Replace("cm", directoryname)
                            .Replace("rmb", directoryname.FirstCharToUpper()).Replace("tmproota", tmproota).Replace("tmprootb", tmprootb);
                            var modulemkpath = string.Empty;
                            if (type == 1)
                            {
                                modulemkpath = newpath + "webng\\src\\app\\modules\\" + directoryname;
                            }
                            if (type == 2)
                            {
                                modulemkpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname;
                            }
                            string modulenm = $"{directoryname}.module.ts";
                            FileUtil.WriteFile(modulemkpath, modulenm, moduletemplate);

                            //创建模块根路由
                            string routetemplate = FileUtil.ReadFile(fileNameRoute);
                            routetemplate = AesEncryptionUtil.AESDecrypt(routetemplate, out msga);
                            if (!msga.IsNull())
                            {
                                result.msg = ImplementResult.Templatefailed.GetRemark();
                                return result;
                            }
                            routetemplate = routetemplate.Replace("table", entityname).Replace("template", model).Replace("cm", directoryname)
                            .Replace("mname", newmodule).Replace("rm", directoryname.FirstCharToUpper());
                            var routemkpath = string.Empty;
                            if (type == 1)
                            {
                                routemkpath = newpath + "webng\\src\\app\\modules\\" + directoryname;
                            }
                            if (type == 2)
                            {
                                routemkpath = newpath + "wb13\\src\\app\\pages\\modules\\" + directoryname;
                            }
                            string routenm = $"{directoryname}-routing.module.ts";
                            FileUtil.WriteFile(routemkpath, routenm, routetemplate);

                            //添加模块路由到项目根目录路径懒加载
                            var proutepath = string.Empty;
                            if (type == 1)
                            {
                                 proutepath = newpath + "webng\\src\\app\\modules\\";
                            }
                            if (type == 2)
                            {
                                 proutepath = newpath + "wb13\\src\\app\\pages\\modules\\";
                            }
                            string proutenm = "index-routing.ts";
                            string proutetemplate = FileUtil.ReadFile(proutepath + proutenm);
                            var prindex = proutetemplate.IndexOf("path: '', redirectTo");
                            if (prindex == -1)
                            {
                                prindex = proutetemplate.IndexOf("path:'',redirectTo");
                            }
                            var addprdata = string.Empty;
                            if (type == 1)
                            {
                                addprdata = "path: '" + directoryname + "', loadChildren: './" + directoryname + "/" + directoryname + ".module#" + directoryname.FirstCharToUpper() + "Module',\n\t\t\tdata: { breadcrumb: '数据管理>" + newmodule + "', preload: true }, canActivate:\t[AuthGuardService]},\n\t\t\t{";
                            }
                            if (type == 2)
                            {
                                addprdata = "path: '" + directoryname + "', loadChildren: () => import('./"+ directoryname + "/"+ directoryname + ".module').then(mod => mod."+ directoryname.FirstCharToUpper() + "Module),\n\t\t\tdata: { breadcrumb: '数据管理>" + newmodule + "', preload: true }, canActivate:\t[AuthGuardService]},\n\t\t\t{";
                            }
                            proutetemplate = proutetemplate.Insert(prindex, addprdata);
                            FileUtil.WriteFile(proutepath, proutenm, proutetemplate);
                        }

                        if (isedit)
                        {
                            if (generators.Any(o => o.iseditdefault == true))
                            {
                                addshow.Append("\t\t<app-formradiogroup [parentInstance]=\"this\" [labelSpan]=\"5\" [controlSpan]=\"14\" [labeltitle]=\"'状态'\"\n\t\t[formControlName] = \"'status'\" [formErrorName] = \"formErrors.status\" [radioData] = \"[{title:'启用',value:1},{title:'停用',value:2}]\" [goalone] = \"true\"></app-formradiogroup>");
                                addshow.Append("\n\t\t<app-formtextarea [parentInstance]=\"this\" [labelSpan]=\"5\" [controlSpan]=\"16\" [labeltitle]=\"'备注'\" [placeholder]=\"'备注'\" [formControlName] = \"'Remark'\" \n\t\t[formErrorName] = \"formErrors.Remark\" [goalone] = \"true\" [Required]=\"false\"></app-formtextarea>");
                            }
                            filename = $"add\\add.component.html";
                            if (!FileUtil.ExistsDir(generatorpath + "\\add"))
                            {
                                FileUtil.CreateDirectory(generatorpath + "\\add");
                            }
                            if (!FileUtil.Exists(generatorpath + "\\" + filename))
                            {
                                json = FileUtil.ReadFile(fileNameHtmlAdd);
                                json = AesEncryptionUtil.AESDecrypt(json, out var msgaa);
                                if (!msgaa.IsNull())
                                {
                                    result.msg = ImplementResult.Templatefailed.GetRemark();
                                    return result;
                                }
                                json = json.Replace("temeplate", addshow.ToString());
                                FileUtil.WriteFile(generatorpath, filename, json);
                            }
                            generatorpath = string.Empty;
                            if (type == 1)
                            {
                                generatorpath = newpath + "webng\\src\\app\\shares\\modules\\" + directoryname;
                            }
                            if (type == 2)
                            {
                                generatorpath = newpath + "wb13\\src\\app\\shares\\modules\\" + directoryname;
                            }
                            string addmodel = $"{directoryname}.module.ts";
                            if (FileUtil.Exists(generatorpath + "\\" + addmodel))
                            {
                                //添加编辑组件到对应模块中
                                string moduleaddjson = FileUtil.ReadFile(generatorpath + "\\" + addmodel);
                                Regex f = new Regex("]");
                                string thname = $", {entityname}AddComponent]";
                                moduleaddjson = f.Replace(moduleaddjson, thname, 2);
                                string adddata = string.Empty;
                                if (type == 1)
                                {
                                    adddata = ";\nimport { " + entityname + "AddComponent } from '../../../modules/" + directoryname + "/" + model + "/add'";
                                }
                                if (type == 2)
                                {
                                    adddata = ";\nimport { " + entityname + "AddComponent } from 'src/app/pages/modules/" + directoryname + "/" + model + "/add'";
                                }
                                moduleaddjson = moduleaddjson.Insert(moduleaddjson.LastIndexOf(';'), adddata).TrimEnd(';');
                                FileUtil.WriteFile(generatorpath, addmodel, moduleaddjson);
                            }
                            else
                            {
                                FileUtil.CreateDirectory(generatorpath);
                                var moduleshareadd = FileUtil.ReadFile(fileNameShareModule);
                                moduleshareadd = AesEncryptionUtil.AESDecrypt(moduleshareadd, out var msgaa);
                                if (!msgaa.IsNull())
                                {
                                    result.msg = ImplementResult.Templatefailed.GetRemark();
                                    return result;
                                }
                                var tmproota = string.Empty;
                                var tmprootb = string.Empty;
                                if (type == 1)
                                {
                                    tmproota = "import { NgZorroAntdModule } from 'ng-zorro-antd';\n\t";
                                    tmprootb = "// tslint:disable-next-line: deprecation\n\tNgZorroAntdModule.forRoot(),\n\t";
                                }
                                moduleshareadd = moduleshareadd.Replace("table", entityname).Replace("rma", directoryname).
                                Replace("model", model).Replace("rmb", directoryname.FirstCharToUpper()).Replace("tmproota", tmproota).Replace("tmprootb", tmprootb);
                                FileUtil.WriteFile(generatorpath, addmodel, moduleshareadd);

                                generatorpath = string.Empty;
                                if (type == 1)
                                {
                                    generatorpath = newpath + "webng\\src\\app\\shares\\shares.module.ts";
                                }
                                if (type == 2)
                                {
                                    generatorpath = newpath + "wb13\\src\\app\\shares\\shares.module.ts";
                                }
                                if (!FileUtil.Exists(generatorpath))
                                {
                                    result.msg = ImplementResult.FileNotExist.GetRemark();
                                    return result;
                                }
                                var addmodule = $"NzDatePickerModule,\n\t\t{directoryname.FirstCharToUpper()}Module,";
                                var moduleshare = FileUtil.ReadFile(generatorpath).Replace("NzDatePickerModule,", addmodule);
                                string adddata = ";\nimport { " + directoryname.FirstCharToUpper() + "Module } from './modules/" + directoryname + "/" + directoryname + ".module'";
                                moduleshare = moduleshare.Insert(moduleshare.LastIndexOf(';'), adddata).TrimEnd(';');
                                var pathb = string.Empty;
                                if (type == 1)
                                {
                                    pathb = "webng\\src\\app\\shares\\";
                                }
                                if (type == 2)
                                {
                                    pathb = "wb13\\src\\app\\shares\\";
                                }
                                FileUtil.WriteFile(newpath + pathb, "shares.module.ts", moduleshare);
                            }
                        }
                    }
                }
                return result;
            });
        }
    }
}
